15 puzzle solver: Difference between revisions
→Time to get Imperative
Line 130:
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[85]{},
unsigned long N2[85]{};
const bool
if (N2[n]==0x123456789abcdef0) return true;
if (N4[n]<=_n) return fN();
return false;
}
const bool fZ(const int w){
if ((w&i)>0){fI(); if (
if ((w&g)>0){fG(); if (
if ((w&e)>0){fE(); if (
if ((w&l)>0){fL(); if (
return false;
}
const bool fN(){
switch(N0[n]){case 0:
case 3:
case 1: case
case
case 15:
case 13: case
case
default:
}
void fI(){
const int g = (11
const unsigned long a = N2[n]&((unsigned long)15<<g);
N0[n+1]=N0[n]+
}
void fG(){
const int g = (19
const unsigned long a = N2[n]&((unsigned long)15<<g);
N0[n+1]=N0[n]-
}
void fE(){
const int g = (14
const unsigned long a = N2[n]&((unsigned long)15<<g);
N0[n+1]=N0
}
void fL(){
const int g = (16
const unsigned long a = N2[n]&((unsigned long)15<<g);
N0[n+1]=N0
}
public:
fifteenSolver(int n
void Solve(){
while (not fN()){n=0;++_n;}
Line 210:
<lang cpp>
int main (){
fifteenSolver start(
start.Solve();
}
|