Hello!
I found in the internet a code:
Code:
#include <stdio.h> 
#include <stdlib.h>  

int main() {    
int n, x;    
printf( "How many disks? " );    
scanf( "%d", &n );    
printf("\n");    
for (x=1; x < (1 << n); x++)       
printf( "move from tower %i to tower %i.\n",(x&x-1)%3, ((x|x-1)+1)%3 ); 

return 0; }
Problem is i cant understand (x&x-1)%3, ((x|x-1)+1)%3 ) that line, i think its something to do with bit operations, but how exactly rings moving forwards and backwards in the towers i cant understand? So maybe someone can help! In here is en.wikipedia.org/wiki/Tower_of_Hanoi something about that in the Binary solution!