We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3fb8535 commit 329d2b9Copy full SHA for 329d2b9
1 file changed
yongjun-0903/쿼드압축 후 개수 세기.py
@@ -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