Class
The focus of this week was on recursion. I had a general sense of what recursion was already, but previous to this course I wouldn't have had an idea of how to program it. In a programming sense, recursion is the use of a function within itself to solve a larger problem. That probably isnt the most transparent definition, so I will use an example.(borrowed from http://stackoverflow.com/questions/479343/how-can-i-build-a-recursive-function-in-python)
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
In this example, to find the factorial of a number involves calling factorial on itself. If we had in input of factorial(3), it would return 3*(factorial(2)). Of course, factorial of two would be 2*(factorial(1), and factorial(1) =1. All this happens within the same function to produce the result of 6. It is a useful concept for solving a problem with many similar and linked parts.
Assignment 1
My partner and I began assignment 1 this week, and I have to say I am enjoying it. As always, when presented with large amounts of code at the beginning it may seem like a towering challenge, but once you dissect it into smaller problems it quickly became easier. At this point we have done steps 1-3, and it was definitely a nice reward that after this point we were able to play a working version of the puzzle. The contrast in this assignment compared to those in 108 is present. While there it seemed we were spoon-fed what to do, and not given much slack in what we could and could not do, I found in 148 there is much more freedom in how we approach a problem.
That's about it for this week!
No comments:
Post a Comment