2018-09-30 22:01:58 +00:00
---
id: 5900f4601000cf542c50ff72
title: 'Problem 244: Sliders'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 301891
2021-01-13 02:31:00 +00:00
dashedName: problem-244-sliders
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2018-09-30 22:01:58 +00:00
You probably know the game Fifteen Puzzle. Here, instead of numbered tiles, we have seven red tiles and eight blue tiles.
2021-07-16 10:21:45 +00:00
A move is denoted by the uppercase initial of the direction (Left, Right, Up, Down) in which the tile is slid, e.g. starting from configuration ($S$), by the sequence $LULUR$ we reach the configuration ($E$):
2018-09-30 22:01:58 +00:00
2021-07-16 10:21:45 +00:00
($S$) < img class = "img-responsive" alt = "configuration S" src = "https://cdn.freecodecamp.org/curriculum/project-euler/sliders-1.gif" style = "display: inline-block; background-color: white; padding: 10px;" > , ($E$) < img class = "img-responsive" alt = "configuration E" src = "https://cdn.freecodecamp.org/curriculum/project-euler/sliders-2.gif" style = "display: inline-block; background-color: white; padding: 10px;" >
2018-09-30 22:01:58 +00:00
For each path, its checksum is calculated by (pseudocode):
2021-07-16 10:21:45 +00:00
$$\begin{align}
& \text{checksum} = 0 \\\\
& \text{checksum} = (\text{checksum} × 243 + m_1) \\; \text{mod} \\; 100\\,000\\,007 \\\\
& \text{checksum} = (\text{checksum} × 243 + m_2) \\; \text{mod} \\; 100\\,000\\,007 \\\\
& \ldots \\\\
& \text{checksum} = (\text{checksum} × 243 + m_n) \\; \text{mod} \\; 100\\,000\\,007
\end{align}$$
2018-09-30 22:01:58 +00:00
2021-07-16 10:21:45 +00:00
where $m_k$ is the ASCII value of the $k^{\text{th}}$ letter in the move sequence and the ASCII values for the moves are:
2018-09-30 22:01:58 +00:00
2021-07-16 10:21:45 +00:00
$$\begin{array}{|c|c|}
\hline
L & 76 \\\\ \hline
R & 82 \\\\ \hline
U & 85 \\\\ \hline
D & 68 \\\\ \hline
\end{array}$$
2018-09-30 22:01:58 +00:00
2021-07-16 10:21:45 +00:00
For the sequence $LULUR$ given above, the checksum would be 19761398. Now, starting from configuration ($S$), find all shortest ways to reach configuration ($T$).
($S$) < img class = "img-responsive center-block" alt = "configuration S" src = "https://cdn.freecodecamp.org/curriculum/project-euler/sliders-3.gif" style = "display: inline-block; background-color: white; padding: 10px;" > , ($T$) < img class = "img-responsive center-block" alt = "configuration T" src = "https://cdn.freecodecamp.org/curriculum/project-euler/sliders-4.gif" style = "display: inline-block; background-color: white; padding: 10px;" >
2018-09-30 22:01:58 +00:00
What is the sum of all checksums for the paths having the minimal length?
2020-11-27 18:02:05 +00:00
# --hints--
2018-09-30 22:01:58 +00:00
2021-07-16 10:21:45 +00:00
`sliders()` should return `96356848` .
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
2021-07-16 10:21:45 +00:00
assert.strictEqual(sliders(), 96356848);
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --seed--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
## --seed-contents--
2018-09-30 22:01:58 +00:00
```js
2021-07-16 10:21:45 +00:00
function sliders() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
2021-07-16 10:21:45 +00:00
sliders();
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```