Skip to content

Instantly share code, notes, and snippets.

@dvrajan
Last active October 7, 2015 09:49
Show Gist options
  • Save dvrajan/03c5bf03d796b41fc7e2 to your computer and use it in GitHub Desktop.
Save dvrajan/03c5bf03d796b41fc7e2 to your computer and use it in GitHub Desktop.
There is a mine grid of size mxn and the mine positions are known by the system. Now, Given a coordinate display the mine grid. If a mine is hit, End the game else continue the game until all the cells are opened.
Input => 3 3 // mine of size 3 x 3
Input => 12 23 33 // mines are at (1,2) (2,3) (3,3)
Output => x x x
x x x
x x x
Input => 1,1
Output => o x x
x x x
x x x
Input => 2,2
Output => o x x
x o x
x x x
.
.
.
Output => o x x
o o x
o o x
Input => 1,3
Output => o x o
o o x
o o x
Output => You won!
Input => 1,2
Output => o x x
x o x
x x x
Output => You hit a mine. Game over!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment