Connect with us:

# Ponder This

Welcome to our monthly puzzles.
You are cordially invited to match wits with some of the best minds in IBM Research.

## June 2023 - Solution

June 2023 Challenge

June 2023 Solution:

The solution to the main problem is 87. For example:

WWWWWFFWFFWFWWFFFWUUURUWFFFUUUURRFRRRUFFFFUUUFRFFFRFFFUURRRRFRRUUURRFUUURRRURUUFRRU RUFFUFUURRRUWRRW

The solution to the bonus is 184 (everything from 179 up was accepted). For example:

FFFFFFFFFFFFUUUUUUURURFRWRWFFFFLRFUWFURWRWUWUWRWFLWFWULWUWRLLLRWUWRLRWRRWLRRWFWU WFWUWURWURWFWFRRRRWUUWFFWFFWFUWFFRFRFFWFFUFLFFLFFLDLFLFLDDLFLDDDDBLDWLDBLDDLDLDLLWLRL RDLRLRDLRLDRLRLBRRDLRDRLLLRDRBRLLL

One possible solution is to treat the maze as a 4-dimensional static grid (with the time t being the additional axis). Move in every axis can be in one direction only, so we can find a solution using dynamic programming techniques where for every grid cell we save the optimal value reachable from this grid cell, computed via the values of its neighbors.

Tim Walters suggested a different route:

“An entertaining way to solve this problem was to treat it as a shortest path problem, with movements from (a,b,c,t) -> (a',b',c',t+1) having weight 1 if there is cheese at the target node, and 1000 if there is none. A shortest path length of 13087 then represents 13 nodes without cheese, and 87 nodes with cheese. It's nice that the cheese times are symmetric in the ordering of a,b,and c, this is the times for (3, 5, 1) are the same as (1,3,5), and any paths through (3, 5, 1) at time t correspond to symmetric paths through (1,3,5). This allows collapsing the node addresses to a canonical form, and significantly reduces computation time and memory space.”

In its original phrasing, the bonus question allowed traversal in the LDB directions, without allowing the mouse to collect the cheese twice for the same cell. This made dynamic programming impossible to use, and rendered the problem much more difficult than intended (we do not know of a solution). The current phrasing of the bonus makes it rather simple.