Welcome to HQ's Blog

Hello World! If you've visited this blog before, welcome back. Please help me what article do you like by give it a comment. But if you're new with this blog, please feel free to stay ahead for a shortwhile, to read my articles. I assure you will get something by read it carefully. Haha...

Ok ok... By the way, this blog belongs to me, Haqqi. Yeah, that is my nickname. If you want to know about me, please read the top sidebar titled "About Me". If you want to know MORE about me, please feel free to add my Messenger (xp_guitarist) and chat with me. I am Indonesian. My English is not so good, so please don't laugh if my 'syntax' is wrong. But sometimes I will post my blog in Bahasa Indonesia (I think most of them will).

The reason I create this blog is, I want to share everything I can share. From my experience, computer program I used, my algorithms and source codes, and some useful infos and tips. So, if you want to request something I can, feel free to ask. And if you also want to share me something, I always open my hand, haha. Anyway, WELCOME TO MY BLOG!

This site is best viewed with Mozilla Firefox with resolution 1024x800 or more

Page copy protected against web site content infringement by Copyscape

ANNOUNCEMENT!!!

This blog is dead!!! I moved it to my new blog in http://haqqi.net. Thank you for reading this blog. Hope you will read my new blog too.


Hanoi Tower

Dec 14, 2008

Ok, another one of my task is finished in just no more than 1 day

Hanoi tower, where we have 3 tower to place n number of pin. Start with tower 1 with all pins, we have to move all the pins to another tower. So easy, isn't it?! Not really!!! We have the rules!!! Bigger pin cannot be placed beyond the smaller pin. So, we can only move a pin to tower which the most top pin is bigger. For 3 number of pins, it easy enough. If we want to move all to 3rd tower, firstly we move 1st pin to 3rd tower. Second, move 2nd pin to 2nd tower. Move again 1st pin to the 2nd tower, beyond the 2nd pin. Move last pin to 3rd tower. Move 1st pin to 1st tower. Move 2nd pin to 3rd tower. Lastly, move 1st pin to 3rd tower. Finish!!!


But for 4 number or more pins, we have to think more. I don't give any algorithm to solve that, since I am too lazy to think that now, maybe next time. But I will give you a simulation game to try to solve the algorithm. Actually, this game is one of my task in my study. I finish it just to give my best to this task, since it will be a big quiz. I use NetBeans IDE 6.1 to develop it, just in 1 day. I know my program is not too perfect, but I think it will be one of the best (so arrogant heh?!). No no... I just want to share this to world.

I will give both of the program and the source code. You can download the program here:
Download link
Or if you want to see my source code and maybe want to give comment, you can download here:
Download link
As usual, use the password to open the zip file:
fauzilhaqqi.blogspot.com

In the program (an executable jar file, just double click it), once you run it, an input dialog box will be displayed. You have to enter number of pin you want, no more than 10. If you enter more than 10, it will be converted to 10 automatically. If you enter negative number, a program will be terminated. You can use right arrow and left arrow on your keyboard to move the cursor. And then press space bar to activate cursor, in order to move the top pin.

Please enjoy using it and give comment if you want.

0 comments: