# The Wizard's Gambit

An evil wizard has captured and thrown you into a dungeon.

This is not a normal dungeon though. It's magical.

Each room has an associated "level" and 9 doors.

The first door can be used to go to the previous room IFF the room level is EVEN.

All the other doors have a number on top of them.

Each time you walk through a door with a number you get to a new room.

The level of the new room is one less than the level of the room you came from. (e.g. if in a room with level 3 and walk through a door with a number you will end up in a room with level 2)

The room you start [the room the evil wizard has dropped you] in is looks like this:

 402  602  701
301    3  699
299  398  598


The center, 3, is the room level. The first door is not show, but it's there. Also, because the level of this room is 3 (i.e. odd) the first door is locked. All the other numbers around the center are the numbers on associated with the other doors in this room.

Keep in mind that if you reach a room with a level of 0 you instantly die.

Being a perfect logical being and given the rules above, you go from room level 3 through all the doors to all reachable rooms with a level of 2 and build the following map. The arrows connect the door with the room you reach.

                    504  704  803
403    2  801
401  500  700
^
|
304  504  603          |          603  803  902
203    2  601 <---+    |    +---> 502    2  900
201  300  500     |    |    |     500  599  799
|    |    |
|    |    |
+    +    +
203  403  502       402  602  701       601  801  900
102    2  500 <----+301    3  699+----> 500    2  898
100  199  399       299  398  598       498  597  797
+    +    +
|    |    |
|    |    |
201  401  500     |    |    |     500  700  799
100    2  498 <---+    |    +---> 399    2  797
98  197  397          |          397  496  696
|
v
300  500  599
199    2  597
197  296  496


To survive/escape you need to find the door marked with number 1004 and walk trough it.

From the initial room, what sequence of doors do you take to escape?

Hint1:

there is a link between the room numbers and the way a knight moves

• Going through a door labeled N seems to add N-500 to all the door numbers. I don't know whether it's always 500, or whether 500 comes from the fact that it's the average of the door numbers, or whether it's something else. – user2357112 supports Monica Mar 16 '15 at 8:57
• how are you labeling the doors? I don't see it. Is it the actual number over the door or the number indicating a door order? – Mircea Mar 16 '15 at 14:33
• The numbers like 602 or 701. – user2357112 supports Monica Mar 17 '15 at 3:21

Any combination of N x1 and NE x2 doors to escape.

Reasoning:

If you subtract the average value of the room's doors from each door, all rooms look like the following.

-98 | 102 | 201
-199 | XXX | 199
-201 | -102 | 98

You can see that backtracking will always get you to where you were, and any combinations of similar moves will also bring you to the same room (ie, N>E is the same as E>N).

Using this we just add any combination of 3 or fewer moves to 500 in order to find 1004. 500 + 102 + 201x2 = 1004, so you need to go N once and NE twice.

This should be the general solution to the problem.

Math:

102*(North-South) + 201*(NorthEast-SouthWest) + 199*(East-West) + 98*(SouthEast-NorthWest) + 500 = 1004
North+South + NorthEast+SouthWest + East+West + SouthEast+NorthWest = 3 Solve that system and you get your values for the directions.

• You only have two moves. If you reach a room with level 0, you immediately die, so you can only move twice (to get to a room with level 1). If door 1004 isn't there, you die when you move through the next door. – Duncan Mar 16 '15 at 20:43
• The final move is through door 1004. So, if you go NE>NE, the N door is 1004. – NotGac Mar 16 '15 at 20:54
• Oh, gotcha. That makes sense now. – Duncan Mar 16 '15 at 20:56

Go through the "top right" door, labeled 701. Then go through the "top middle door" labeled 803. The "top right" door should now be 1004, while the middle door is just 1.

Rationale:

Passing through each door does something to all the numbers. The central number always decreases by one, but all the other numbers are affected in the same way. For example, going through the "bottom middle" door (398) decreases all numbers by 102. Going through the "middle right" door (699) increases all numbers by 199.

So:

Going through door 701 increases all numbers by 201. Then going through the top middle door (which is now 803) every number should increase by 102.

Thus:

The "upper right" door will go from 701->902->1004 while the level of the room has decreased 3-2-1. The caveat of only being able to go backwards if the room is of even level is just to make sure you can explore the first steps, while not being able to go two steps and then come backwards to just keep exploring to find the right door.

• in the answer you say 703. do you mean 701? intuitively this is the right path. Are you sure the numbers will be mutated the same way when you go from level 2 to level 1? – Mircea Mar 16 '15 at 5:23
• yes, I do mean 701 and will edit. I don't know that the changes will be the same going from level 2 to level 1, but if there is some difference then the clue is subtle enough that I didn't spot it! – Duncan Mar 16 '15 at 7:39
• the clue is in the puzzle's name. BTW: 701->902->1004 is a valid answer to the puzzle, it's just than I'm not convinced of the reasoning behind it. – Mircea Mar 16 '15 at 14:35
• Well, I'll clarify my reasoning - when you go through a door, each door in the new room will have increased by a constant from its corresponding door in the previous room. Thus the "top left" door starts at 402. If go through door 301, then the "top left" door has decreased by 199 (from 402 to 203). One other thing I noticed is that the doors follow a pattern. From lower left corner, moving clockwise, the doors go: +2, +101, +200, +99, -2, -101, -200, -99. I don't know if that plays into it. – Duncan Mar 16 '15 at 20:56
• @Mircea: Are we making knight moves? – user2357112 supports Monica Mar 17 '15 at 3:22

There seems to be a pattern in calculating the new room numbers when moving to any new room (from the level 3 room) as follows:

For a room with door numbers

      A  B  C
d     D
c  b  a


Step 1) Let N equal half the difference between the number of the door you choose and the diagonally opposite door. For example, choosing door A above, N = (A-a)/2, or choosing b : N = (b - B)/2.

Step 2) Add N to each of A, B, C... to get the numbers for the new room.

This pattern holds for all the doors explored so far.

If this rule is also maintained when moving from a level 2 room then the solution is to move up through door 602 to room

      504  704  803
403    2  801
401  500  700


then move up and diagonally to the right through door 803. According to the pattern,

From Step 1) N = (803-401)/2 = 201

From step 2) the expected door numbers are

      705  905  1004
604    2  1002
602  701  902


and you can now escape through room 1004 by moving up and diagonally to the right again. Of course, you can't guarantee that the same pattern will hold...