15 puzzle solver: Difference between revisions

Content added Content deleted
No edit summary
Line 1: Line 1:
{{draft task|Games}}
{{task|Games}}
Your task is to write a program that solves the [[wp:15_puzzle|Fifteen Puzzle Game]] in the fewest number of moves.<br />
Your task is to write a program that finds a solution in the fewest moves possible to a random [[wp:15_puzzle|Fifteen Puzzle Game]].<br />
For this task you will be using the following puzzle:<br />
For this task you will be using the following puzzle:<br />
<pre>15 14 1 6
<pre>15 14 1 6
Line 11: Line 11:
5 6 7 8
5 6 7 8
9 10 11 12
9 10 11 12
13 14 15 0</pre>
13 14 15 0
</pre>

The output must show the moves' directions, like so: left, left, left, down, right... and so on.<br />
The output must show the moves' directions, like so: left, left, left, down, right... and so on.<br />
;Extra credit.
Solve the following problems:
<pre>
2 1 3 4
5 6 7 8
9 10 11 12
13 14 15 0
</pre>
and
<pre>
0 12 9 13
15 11 10 14
3 7 2 5
4 8 6 1
</pre>
=={{header|C++}}==
=={{header|C++}}==
===The Solver===
===The Solver===