OOAIA-A12

to
Starts in

About

The game is played on an N X N grid of 'cells', each of which is either empty or contains an explosive mine. The player's task is to locate all of the M mines without causing any of them to explode. The location of the mines however, is a secret to the player. At the beginning of the game the player has no information as to whether any given cell contains a mine or not. The only course of action is to 'reveal' the contents of a chosen cell. Should the player choose to reveal a mine, the game is over and the player loses. However, if an empty cell is revealed, two useful things will happen. - The player is shown, how many of the revealed cell's eight neighbours contain mines. - If the chosen cell has no neighbours which are mines, all of its neighbours are 'revealed'.

To understand the game further, play the game a few times to get the hang of it. It can be played here: \url{http://minesweeperonline.com/}.

Your task is to design a minesweeper game given the values of N (the size of the grid) and M (the number of mines) and the locations of all the mines. Once these values are given, the board has been set. Now the player begins to play, and the positions where he chooses to click are given. For each 'click', you must print one of the following: - "Won" if all the cells except the mines have been revealed. - "Lost" if a mine has been revealed. - A number "x" where x is the number of cells that have been revealed up to this point which are not mines.

Once "Won"/"Lost" has been printed, the further locations do not matter and must be ignored.

Use appropriate classes and functions to design your program.

Rules

  • The creator of this contest is solely responsible for setting and communicating the eligibility requirements associated with prizes awarded to participants, as well as for procurement and distribution of all prizes. The contest creator holds HackerRank harmless from and against any and all claims, losses, damages, costs, awards, settlements, orders, or fines.
  • Code directly from our platform, which supports over 30 languages. Learn more here.

Scoring

  • Each challenge has a pre-determined score.
  • A participant’s score depends on the number of test cases a participant’s code submission successfully passes.
  • If a participant submits more than one solution per challenge, then the participant’s score will reflect the highest score achieved. In a game challenge, the participant's score will reflect the last code submission.
  • If a participant submits more than one solution per challenge, then the participant’s score will reflect the highest score achieved.
  • Participants are ranked by score. If two or more participants achieve the same score, then the tie is broken by the total time taken to submit the last solution resulting in a higher score

Sign up for OOAIA-A12 now.

Not a genuine coding contest?