P313
projecteuler.net

Sliding Game

ℹ️Published on Sunday, 5th December 2010, 04:00 am; Solved by 1786;
Difficulty rating: 30%

In a sliding game a counter may slide horizontally or vertically into an empty space. The objective of the game is to move the red counter from the top left corner of a grid to the bottom right corner; the space always starts in the bottom right corner. For example, the following sequence of pictures show how the game can be completed in five moves on a $2$ by $2$ grid.

0313_sliding_game_1.gif

Let $S(m,n)$ represent the minimum number of moves to complete the game on an $m$ by $n$ grid. For example, it can be verified that $S(5,4) = 25$.

0313_sliding_game_2.gif

There are exactly $5482$ grids for which $S(m,n) = p^2$, where $p \lt 100$ is prime.

How many grids does $S(m,n) = p^2$, where $p \lt 10^6$ is prime?



Soluzione

Last modified: May 01, 2025. Website built with Franklin.jl and the lovely Julia programming language.