https://school.programmers.co.kr/learn/courses/30/lessons/120841
아니 이것만큼은 일차원적인 방법 말고 없다 라고 단언하고 냅다 if문 분화했는데
def solution(dot):
if dot[0] > 0:
if dot[1] > 0:
return 1
else:
return 4
else:
if dot[1] > 0:
return 2
else:
return 3
거짓이 0이고 참이 1이니까 그걸로 인덱스를 넣어서 하는 방법으로 푼 사람이 있었다
def solution(dot):
result = [[3, 2], [4, 1]]
return result[dot[0] > 0][dot[1] > 0]
대단행..
'코테 공부 > python' 카테고리의 다른 글
Python 빈 배열에 인덱스 할당 불가 (0) | 2023.05.30 |
---|---|
Python 이중 배열 append (0) | 2023.05.30 |
Python math.factorial(n) math.comb(n, r) (0) | 2023.05.30 |
Python map (0) | 2023.05.30 |
Python sorted(iterable데이터), 리스트.sort() (0) | 2023.05.29 |