Introduction

This is the solution for the December 2022’s Jane Street puzzle. Check out the original post on the Jane Street website.

The Puzzle

Board

A six-sided die, with numbers written on each of its faces, is placed on the 6-by-6 grid above, in the lower-left (yellow) corner. It then makes a sequence of “moves”. Each move consists of tipping the die into an orthogonally adjacent square within the grid.

The die starts with a “score” of 0. On the Nth move, its score increases by N times the value of the die facing up after the move. However, the die is only allowed to move into a square if its score after the move matches the value in the square. Also, the die cannot be translated or rotated in place in addition to these moves.

After some number of moves the die arrives in the upper-right (blue) corner.

The answer to this puzzle is the sum of values in the unvisited squares from the die’s journey.

Solution

For this puzzle, I utilized Python due to its efficient implementation capabilities. I began by creating classes to represent the board and die, keeping track of position and score. Initially, the die did not have any numbers assigned to its faces. When the die was moved, there were two possible scenarios:

  1. The value of the upper face of the die had not yet been set: In this case, I needed to calculate the value of the die’s face and verify that it was valid.
  2. The upper face of the die already had a value: In this instance, I needed to ensure that the value on the square matched the die’s score.

If either of these cases was not valid, the move was deemed invalid. I utilized recursion, with the stopping condition being when the die reached the upper-right corner. After a solution was found, I simply counted the sum of the values in the unvisited squares to arrive at the final answer: 1935. The board showing the die’s path is depicted below.

Solution

And just for the curious ones, this is the value of the die’s faces at the starting position:

Die

And this is the link to the solution from Jane Street Link

Final notes

This was a fun puzzle to solve and definitely easier compared to the previous one ( Pent up frustration 2) as can be seen from the number of successful submissions.

You can also take a look at the code behind my solution on GitHub.

Do you want to take a look at more puzzles? Check out here