Skip to content

Commit 329d2b9

Browse files
authored
� Study: 쿼드압축 후 개수 세기 (#59)
1 parent 3fb8535 commit 329d2b9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def solution(arr):
2+
n = len(arr)
3+
total = sum(map(sum, arr))
4+
5+
if total == 0:
6+
return [1, 0]
7+
if total == n * n:
8+
return [0, 1]
9+
10+
half = n // 2
11+
top_left = [row[:half] for row in arr[:half]]
12+
top_right = [row[half:] for row in arr[:half]]
13+
bottom_left = [row[:half] for row in arr[half:]]
14+
bottom_right = [row[half:] for row in arr[half:]]
15+
16+
return [sum(s) for s in zip(
17+
solution(top_left),
18+
solution(top_right),
19+
solution(bottom_left),
20+
solution(bottom_right)
21+
)]

0 commit comments

Comments
 (0)