-
Notifications
You must be signed in to change notification settings - Fork 0
/
bomb_bazi.py
75 lines (68 loc) · 1.66 KB
/
bomb_bazi.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import numpy as np
n, m = map(int,input().split(' '))
zero = np.zeros((n,m))
k = int(input())
def bomb(i,j,m):
if i == 1:
if j == 1:
m[i][j-1] += 1
m[i-1][j] += 1
m[i][j] += 1
elif j == len(m[0]):
m[i-1][j-2] += 1
m[i][j-1] += 1
m[i][j-2] += 1
else:
m[i][j-1] += 1
m[i-1][j] += 1
m[i-1][j-2] += 1
m[i][j-2] +=1
m[i][j] +=1
elif i == len(m):
if j == 1:
m[i-1][j] += 1
m[i-2][j-1] += 1
m[i-2][j]
elif j == len(m[0]):
m[i-1][j-2]+= 1
m[i-2][j-2] += 1
m[i-2][j-1] += 1
else:
m[i-1][j] += 1
m[i-2][j-1] += 1
m[i-1][j-2] +=1
m[i-2][j-2] += 1
m[i-2][j] += 1
else:
if j == 1:
m[i-2][j-1] += 1
m[i-2][j] += 1
m[i-1][j] +=1
m[i][j-1] +=1
m[i][j] +=1
elif j == len(m[0]):
m[i-2][j-1] +=1
m[i-2][j-2] +=1
m[i-1][j-2] +=1
m[i][j-1] +=1
m[i][j-2] +=1
else:
m[i-1][j] += 1
m[i-1][j-2] +=1
m[i][j-1] += 1
m[i-2][j-1] += 1
m[i][j] += 1
m[i][j-2] += 1
m[i-2][j-2] +=1
m[i-2][j] += 1
return(m)
for i in range(k):
i,j = map(int,input().split(' '))
zero[i-1][j-1] = 9
zero = bomb(i,j,zero)
z = zero.tolist()
for i in z:
i = [str(int(x)) if x < 9 else '*' for x in i]
for j in i:
print(j, end= ' ')
print()