The week started off with my group mates and I beginning to work on our TOAH assignment. Upon first seeing the assignment, the instructions were confusing and the overall coding was vague to us. We did research and began to understand more of what the concept of stacking cheese was. It turns out it is a very popular problem and the best proposed solution is an algorithm called the Frame Stewart algorithm. This however did not help us in the coding aspects of the first 2 steps in the assignment. We added methods such as add and remove in order to move the cheese around the stools. We also defined global variables in order to be able to work with our lists globally which was taught to us in class this week as well. We used a dictionary to store our stools as keys and a list of integers for our cheeses that is stacked upon the stools as the value. Our various methods such as add and remove will help in moving cheese from one stool to another while altering the global dictionary that we made which is our actual TOAH. We are still working on our assignment and struggling but progress is being made.
What we did in tutorials this week was tracing and writing recursive functions. Even though recursion was talked about in class for a while, the actual application of it was different from simply listening. Initially, my partner and I were running a recursive function with a for loop. However, we failed to return a value in our second else statement which caused the function to continue without stopping. We expected that the recursive function would only work given that we used a for loop. We were told that we could do it without a loop and with simple if and else statements. We then changed our loop into if statements and got the function to run as it should. Our understanding of recursive has increased after the tutorial.
No comments:
Post a Comment