Skip to content

Instantly share code, notes, and snippets.

@peacher5
Created December 1, 2017 05:26
Show Gist options
  • Select an option

  • Save peacher5/b6897ea8df663d127a98724ca118dbc6 to your computer and use it in GitHub Desktop.

Select an option

Save peacher5/b6897ea8df663d127a98724ca118dbc6 to your computer and use it in GitHub Desktop.
Minesweeper Elab
size = [int(x) for x in input().split('x')]
table = [[0] * size[1] for row in range(size[0])]
bombs = []
for i in range(int(input())):
bomb = [int(x) for x in input().split(',')]
bombs.append(bomb)
for bomb in bombs:
table[bomb[0]][bomb[1]] = '*'
for row in range(bomb[0] - 1, bomb[0] + 2):
if row >= 0 and row < size[0]:
for col in range(bomb[1] - 1, bomb[1] + 2):
if col >= 0 and col < size[1] and table[row][col] != '*':
table[row][col] += 1
for rows in table:
for i in rows:
print(i, end='')
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment