15 puzzle solver: Difference between revisions

(→‎{{header|C++}}: Imperative solution < 1 sec)
Line 123:
sys 0m0.008s
</pre>
===Time to get ImperetiveImperative===
====The Solver====
<lang cpp>
Line 129:
class fifteenSolver{
const int Nr[16]{3,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3}, Nc[16]{3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2}, i{1}, g{8}, e{2}, l{4};
int n{},_n{}, N0[8085]{},N1[8085]{},N3[8185]{},N4[8085];
unsigned long N2[8085]{};
bool fU(){
if (N2[n]==0x123456789abcdef0) return true;
Line 154:
case 'r': return fZ(i+e);
case 'u': return fZ(e+l);
default : return fZ(i+e+l);}}
case 3: switch(N1[n]){case 0: switch(N3[n]){case 'l': return fZ(g);
case 'd': return fZ(e);
Line 203:
void Solve(){
while (not fN()){n=0;++_n;}
std::cout<<"Solution found in "<<n<<" moves: "; for (int g{01};g<=n;++g) std::cout<<(char)N3[g]; std::cout<<std::endl;
}
};
2,172

edits