The code is working but it aims to solve the tower of hanoi!
And some changes need to be made in order to make it work. The changes are per character and maximum 10 such changes are available:
#include
#include
static signed char a[] = {'i','n','v','a','l','i','d','\0','b','y','e','\0','r','e','m','o','v','e',' ','%','d',' ','f','r','o','m',' ','%','s',' ','t','o',' ','%','s','\n','\0'}, *b = a+8, *c = a+14, *w, *x, *u, *y, *z; int main(int d, char *e[]) {int r, n;return r=(d==6?0*(*(y=e[2]),*(u=e[3]),*(z=e[4])):0*puts(a) +1)||(((w = e[1]) && w[0] == 's')?0:0*puts(b) + 1)||((w[1] == 'o')?0:0*puts(b) + 1)||((w[2] == 'l')?0:0*puts(b) + 1)||((w[3] == 'v')?0:0*puts(b) + 1)||((w[4] != 'e')?0*puts(b) + 1:((n=atoi(x=e[5])),(n ==1)?0*printf(c, n, e[2], e[3]):(sprintf(x, "%d", n-1),e[3]=z,e[4]=u, main(6,e),printf(c,n, e[2], e[4]),e[2] = z,e[3] = u, e[4] = y, main(6, e), e[2]=y,e[3] = u, e[4] = z,sprintf(x, "%d", n))));}
I know it's real ugly maybe i might help in a bit of indentation:
#include
#include
static signed char a[] = {'i','n','v','a','l','i','d','\0','b','y','e','\0','r','e','m','o','v','e',' ','%','d',' ','f','r','o','m',' ','%','s',' ','t','o',' ','%','s','\n','\0'}, *b = a+8, *c = a+14, *w, *x, *u, *y, *z;
int main(int d, char *e[])
{
int r, n;
return r=(d==6?0*(*(y=e[2]),*(u=e[3]),*(z=e[4])):0*puts(a) +1)||(((w = e[1]) && w[0] == 's')?0:0*puts(b) + 1)||((w[1] == 'o')?0:0*puts(b) + 1)||((w[2] == 'l')?0:0*puts(b) + 1)||((w[3] == 'v')?0:0*puts(b) + 1)||((w[4] != 'e')?0*puts(b) + 1:((n=atoi(x=e[5])),(n ==1)?0*printf(c, n, e[2], e[3]):(sprintf(x, "%d", n-1),e[3]=z,e[4]=u,e[5]=x, main(6,e),printf(c,n, e[2], e[4]),e[2] = z,e[3] = u, e[4] = y, main(6, e), e[2]=y,e[3] = u, e[4] = z,sprintf(x, "%d", n))));
}
Well refer to the original code of tower of hanoi. Here's a snapshot of it:
#include
int towerOfHanoi(int noOfDisc,
char source,
char destination,
char third
) // towerHanoi.c
{
if(noOfDisc == 0) { return 0; } // Basis
{
int noOfMoves ;
& %
noOfMoves = towerOfHanoi(noOfDisc-1,
source, third, destination);
printf("%c -> %c ", source, destination);
++ noOfMoves ;
noOfMoves += towerOfHanoi(noOfDisc-1,
third, destination, source);
return noOfMoves ;
}
}
So this is a generic code.... u might run the buggy code by:
./a.out solve s d t 10
Here s is source
d-destination
t-third pole
10 is the value to solve
Help me guys...
No comments:
Post a Comment