Under construction

Still being built. Things may change

Hunt the Wumpus

Interview

Time limit1sMemory limit1024 MB

Summary
Given a seeded generator that places four wumpuses on a 10x10 grid, report each guess's hit status and the Manhattan distance to the nearest remaining wumpus.
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

Hunt the Wumpus is a game you play against the computer on a 10×1010 \times 10 grid. At the start, four wumpuses are placed randomly on the grid, with no two sharing a square. You must find and capture all four. You guess a square by entering its coordinates as two decimal digits. If your guess is a wumpus, the game tells you so, and that wumpus is captured and removed from the grid. Whether or not you hit a wumpus, the game reports the Manhattan distance between your guess and the nearest remaining wumpus. You use this distance to narrow down where each wumpus is. The game ends when the last wumpus is captured.

You are writing the computer side of the game. A guess or a randomly generated wumpus location is a two-digit number, where the tens digit is xx and the ones digit is yy, giving the point (x,y)(x, y).

To make the game deterministic, the program uses its own pseudo-random number generator with a given seed ss. Each random number is produced by first setting s←s+⌊s/13⌋+15s \leftarrow s + \lfloor s/13 \rfloor + 15 and then returning the two low digits of ss. The first four distinct numbers generated are the wumpus locations. For a seed of 132, the first number is the two low digits of 132+10+15132 + 10 + 15, which is 57, corresponding to the point (5,7)(5, 7).

Input

The first line contains a single integer ss (104≤s≤10610^4 \le s \le 10^6), the seed for the random number generator. Each of the remaining lines contains a two-digit number (leading zeros allowed). Each number is one of the player's guesses, corresponding to one grid square.

The input is always well-formed and describes a complete game. The last guess always finds the last wumpus. There are at most 250 guesses.

Output

For each guess, output the computer's response. If the guess hits a wumpus, output You hit a wumpus! on its own line. Whether or not the guess hit, if any wumpuses remain uncaptured, output the Manhattan distance to the nearest remaining wumpus. The Manhattan distance between (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is ∣x1−x2∣+∣y1−y2∣|x_1 - x_2| + |y_1 - y_2|, always an integer.

When the game ends, output the total number of moves mm needed to locate all the wumpuses in the form Your score is $m$ moves. on its own line.

Examples2

  1. Example 1

    Input
    203811
    00
    01
    02
    03
    
    Expected output
    You hit a wumpus!
    1
    You hit a wumpus!
    1
    You hit a wumpus!
    1
    You hit a wumpus!
    Your score is 4 moves.
    
  2. Example 2

    Input
    101628
    00
    40
    60
    68
    78
    95
    
    Expected output
    4
    You hit a wumpus!
    2
    You hit a wumpus!
    8
    1
    You hit a wumpus!
    5
    You hit a wumpus!
    Your score is 6 moves.