Advertisement
3xbun

Minesweeper

Dec 11th, 2017
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. def plotTable(m, n):
  2.     table = []
  3.     for h in range(m):
  4.         for w in range(n):
  5.             table.append([h, w])
  6.     return table
  7.  
  8. def getMine(bomb):
  9.     counter = 0
  10.     mines = []
  11.     while counter < bomb:
  12.         mine = input().split(',')
  13.         mines.append([int(mine[0]), int(mine[1])])
  14.         counter += 1
  15.     return mines
  16.  
  17. def plotMines(table, mines):
  18.     for mine in mines:
  19.         table[table.index(mine)] = 'mine'
  20.     return table
  21.  
  22. def printTable(table, m, n):
  23.     counter = 0
  24.     for h in range(1, m + 1):
  25.         for w in range(1, n + 1):
  26.             if table[counter] == 'mine': print('*', end='')
  27.             else: print(0, end='')
  28.             counter += 1
  29.         print()
  30.  
  31. table = input().split('x')
  32. m, n = int(table[0]), int(table[1])
  33. bomb = int(input())
  34. mines = getMine(bomb)
  35.  
  36. table = plotTable(m, n)
  37. newTable = plotMines(table, mines)
  38. printTable(newTable, m, n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement