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.

No comments:

Post a Comment