15 puzzle solver: Difference between revisions
Content added Content deleted
(→Time to get Imperative: Extra Credit) |
|||
Line 202: | Line 202: | ||
fifteenSolver(int n, unsigned long g){N0[0]=n; N2[0]=g; N4[0]=0;} |
fifteenSolver(int n, unsigned long g){N0[0]=n; N2[0]=g; N4[0]=0;} |
||
void Solve(){ |
void Solve(){ |
||
⚫ | |||
while (not fN()){n=0;++_n;} |
|||
else {n=0; ++_n; Solve();} |
|||
⚫ | |||
} |
} |
||
}; |
}; |
||
Line 222: | Line 222: | ||
sys 0m0.000s |
sys 0m0.000s |
||
</pre> |
</pre> |
||
====Extra Credit==== |
|||
I have updated the 20 random examples, which showed n the number of moves to include _n. As seen when _n is less than 10 the puzzle is solved quickly. This suggests a multi-threading strategy. I have 8 cores available. Modifying solve so that it starts a thread for _n=0 to _n=9, 1 for _n=10, 1 for _n=11, 1 for _n=12, and 1 for _n=13 tests that the fan is still working and turns the computer into a hair-dryer. It also finds the following solution to the extra credit task: |
|||
<pre> |
|||
Solution found in 80 moves: dddrurdruuulllddrulddrrruuullddruulldddrrurulldrruulldlddrurullddrrruullulddrdrr |
|||
<pre> |
|||
in 29m19.973s. |
|||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |