forked from MiyabiTane/myLeetCode_
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Women_in_Tech.py
52 lines (49 loc) · 1.26 KB
/
Women_in_Tech.py
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
def judge(board):
def Dangojudge(array):
count=0
for st in array:
if st=='o':
count+=1
if count==3:
return 1
else:
count=0
return 0
#checkpoint1
for i in range(5):
row=[board[i][j] for j in range(5)]
check1=Dangojudge(row)
if check1==1:
return "Dango"
#checkpoint2
for i in range(5):
col=[board[j][i] for j in range(5)]
check2=Dangojudge(col)
if check2==1:
return "Dango"
#checkpoint3
for diff in range(-2,3):
diag=[]
for i in range(5):
for j in range(5):
if i-j==diff:
diag.append(board[i][j])
check3=Dangojudge(diag)
if check3==1:
return "Dango"
for sum in range(2,7):
diag=[]
for i in range(5):
for j in range(5):
if i+j==sum:
diag.append(board[i][j])
check3=Dangojudge(diag)
if check3==1:
return "Dango"
return "Dango deha nai yo!"
ans=judge([['x','o','x','o','o'],
['o','o','x','o','x'],
['o','x','x','x','o'],
['x','o','x','o','o'],
['o','o','x','o','x']])
print(ans)