Shell Script for Tower of Hanoi
hello CEans
Can anyone please help with a shell script for Tower of Hanoi ? 😕
as we cannot pass parameters to functions in Linux please tell a program in c/c++ otherwise but without use of recursion so that it can be translated into Linux shell script syntax
Thanks
Can anyone please help with a shell script for Tower of Hanoi ? 😕
as we cannot pass parameters to functions in Linux please tell a program in c/c++ otherwise but without use of recursion so that it can be translated into Linux shell script syntax
Thanks
Replies
-
Manish Goyal
#include
This is not my creation ..hope it will help you#include 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; } -
sarveshguptathanks a lot goyal
But you are sure that it will work! so can i use it directly without checking as i have the exam tomorrow itself
Also can you explain it a little bit what is the code doing by taking an example of 3 disks -
Manish Goyalsorry ...i can't explain you..but i am sure it will work...I have tested it...
as it is not created by me...... -
sarveshguptaOk thanks a lot ! 😁
You are reading an archived discussion.
Related Posts
I am mother of two kids and i believe that in todays modern world kids should have better understanding of indian culture. I came across an educational kids website ...
The title pretty much says it all.
I'm not an engineer but have been tinkering (mostly with computers) and various inventions my whole life.
I wanted to build a mini...
Intel has announced new Intel Atom processors that feature integrated graphics built directly into the CPU, enabling improved performance and smaller, more energy-efficient designs in a new generation of netbooks....
Guys. Can you help me out with the companies where i can do Industrial training during Summer..
Infosys is conducting joint campus placement. Please tell me the tips and tricks to score in the written test.
what topics and which books should I prefer?
what are the...