Sunday, February 16, 2014

Reading Week

I planned to use this reading week to review for m test. It seems that lots of things I need to catch up.

For last week Assignment 1, I want to comment about the function to calculate i. I think this would be the hardest part in the whole assignment. I knew that I need to use the M(n) on the handout, but it was pretty tricky to come up with an optimal solution. Then I googled a lot for some hint, and finally found an article suggest that the steps, M(n), should be tested 'i' one by one and then find the smallest M(n). That was very helpful and after several tries I can find the smallest M(n). However, it was not over. I still need to redirect to the 'i'. First time I tried use a loop to get the i, but found it is too slow because when I did the loop, I call the recursion thousands of times. After struggle for 2 days, I recalled that I can use a memory to take the result down each time, which I can recall from instead of doing the same recursion again and again. Then I choose use a dictionary. After that, all the problems were solved. My program can run the 150 cheeses with smallest step within 1 min.

Sunday, February 9, 2014

LEARN FROM HANOI

This week I spend much time figuring the step 5, namely the recursion question, in the Hanoi Puzzle. After the Monday lecture I understood the sight of solving recursion problem, and finished the three stools problem. I thought it wold be similar for the four stools, but found much harder.

By many tries, I finally finished the program but I still feel vague about the whole process. There are still many steps that I find hard to trace. However, through this assignment I have a basic framework about how to separate a recursive question into parts and divide them to base cases and recursive cases. It's just time that I need to understand it better.

In conclusion, recursive function requires a way that you focus your mind on solving only one cycle of the problem and leave the rest to the computer who can auto-run it by itself. Moreover, it's important to add condition operator to each cases, which avoids unexpected error.

Monday, February 3, 2014

Recursion

These days I have been busy about the Assignment 1. In the assignment, there is a puzzle called Tower of Hanoi. Actually the first 4 steps are easy, which require to follow the instruction and comment to fill the blank and make the program functional. However the fifth step was so hard that I struggled for 2 days but still stand in still!

That step require to think of an method to automatically run the game and find the least-step solution. I knew that recursion is required in that method but can' t find a clue. After the Monday lecture and some searching job on the Wiki, I can understand most of the three stools method. It will take me more time, let's say at least a week, to come to the method for four stools.

Therefore, recursion is easy to trace and understand but hard to generate your own recursion. It requires your better understanding of the puzzle and the ability to separate it into several steps.