2018-10-10 18:03:03 -04:00
---
id: 5900f4a61000cf542c50ffb8
2021-02-06 04:42:36 +00:00
title: 'Problem 313: Sliding game'
2018-10-10 18:03:03 -04:00
challengeType: 5
2021-02-06 04:42:36 +00:00
forumTopicId: 301969
2021-01-13 03:31:00 +01:00
dashedName: problem-313-sliding-game
2018-10-10 18:03:03 -04:00
---
2020-12-16 00:37:30 -07:00
# --description--
2020-02-18 01:40:55 +09:00
2021-02-06 04:42:36 +00:00
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.
2020-02-18 01:40:55 +09:00
2021-02-06 04:42:36 +00:00
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.
2020-02-18 01:40:55 +09:00
2021-02-06 04:42:36 +00:00
There are exactly 5482 grids for which S(m,n) = p2, where p < 100 is prime.
2020-02-18 01:40:55 +09:00
2021-02-06 04:42:36 +00:00
How many grids does S(m,n) = p2, where p < 106 is prime?
2020-02-18 01:40:55 +09:00
2020-12-16 00:37:30 -07:00
# --hints--
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`euler313()` should return 2057774861813004.
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert.strictEqual(euler313(), 2057774861813004);
2018-10-10 18:03:03 -04:00
```
2021-01-13 03:31:00 +01:00
# --seed--
## --seed-contents--
```js
function euler313() {
return true;
}
euler313();
```
2020-12-16 00:37:30 -07:00
# --solutions--
2020-08-13 17:24:35 +02:00
2021-01-13 03:31:00 +01:00
```js
// solution required
```