Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def printpretty(x):
- for row in x:
- print(' '.join(row))
- def summ_mines(i, j, arr):
- summ = 0
- for x in range(i - 1, i + 2):
- for y in range(j - 1, j + 2):
- if x == -1 or x == len(arr) or y == -1 or y == len(arr[x]):
- continue
- if arr[x][y] == '*':
- summ += 1
- return summ
- inp = input().split()
- strings = int(inp[0])
- vert = int(inp[1])
- num_mines = int(inp[2])
- summ = 0
- mines = []
- for i in range(num_mines):
- mines.append(input().split())
- mines = [list(map(int, i)) for i in mines]
- res = [['*' if mines.count([i + 1, j + 1]) == 1 else '.' for j in range(vert)] for i in range(strings)]
- for i in range(strings):
- for j in range(vert):
- if mines.count([i + 1, j + 1]) == 1:
- res[i][j] == '*'
- else: res[i][j] == '.'
- for i in range(strings):
- for j in range(vert):
- if res[i][j] != '*':
- res[i][j] = str(summ_mines(i, j, res))
- printpretty(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement