-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzofip_15_bingo.py
More file actions
108 lines (100 loc) · 2.13 KB
/
zofip_15_bingo.py
File metadata and controls
108 lines (100 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
##import numpy as np
##
###가로,세로,대각선 왕중왕전
##
##def value(a,b,cnt):
## if a > b:
## b = a
## cnt = 1
## elif a == b:
## cnt += 1
## return a,b,cnt
##
##def rowvalue(k):
## cnt = 0
## max_cnt = 0
## for i in k:
## if i == 1:
## cnt += 1
## max_cnt = max(cnt, max_cnt)
## else:
## cnt = 0
## return max_cnt
##
##def solve(arr,a,b,cnt):
## (n,m) = arr.shape
## ttl = []
## for i in range(n):
## ttl.append(list(arr[i]))
## for j in range(m):
## ttl.append(list(arr[:,j]))
##
## reverse = np.fliplr(arr)
## for k in range(-n+1, m):
## ttl.append(list(np.diag(arr,k)))
## ttl.append(list(np.diag(reverse,k)))
##
## for l in ttl:
## a = rowvalue(l)
## _,b,cnt = value(a,b,cnt)
##
## return b,cnt
##
##
##
###입력한 표 arr만들기
##bingo = []
##while True:
## try:
## line = list(input())
## bingo.append(line)
## except:
## break
##
##arrr = np.array(bingo, dtype=np.int8)
##print(*solve(arrr,0,0,0))
import numpy as np
def value(a, b, cnt):
if a > b:
b = a
cnt = 1
elif a == b:
cnt += 1
return a, b, cnt
def rowvalue(k):
max_cnt = 0
cnt = 0
for i in k:
if i:
cnt += 1
max_cnt = max(cnt, max_cnt)
else:
cnt = 0
return max_cnt
def solve(arr):
n, m = arr.shape
ttl = []
for i in range(n):
ttl.append(list(arr[i]))
for i in range(m):
ttl.append(list(arr[:, i]))
reverse = np.fliplr(arr)
for k in range(-n+1, m):
ttl.append(list(np.diag(arr, k)))
ttl.append(list(np.diag(reverse, k)))
b = 0
cnt = 0
for l in ttl:
a = rowvalue(l)
_, b, cnt = value(a, b, cnt)
return b, cnt
# 입력한 표 arr 만들기
bingo = []
while True:
try:
line = list(input())
bingo.append(line)
except:
break
arrr = np.array(bingo, dtype=np.int8)
print(*solve(arrr))