This week was a hectic week, with Assignment #2 due on Tuesday and a heavy duty lab. I'm still trying to familiarize myself with the concept of recursion. Over the weekend, I was trying to find someway to use lists to complete part a of the assignment, but after going to the help centre, this really nice and patient TA helped me reframe my approach to the problem. He helped me visualize the problem in a top-down way. The bigger problem was broken down into simpler cases that the function could then call upon itself recursively to solve more complex problems. Though I was really happy that it made sense to me, and that this type of approach is the way the course work has been trying to get us to wrap our head around, it meant that I spent the entire weekend trying to implement the function in a way that I ended up scrapping and having to start over. Although to be fair, the lovely thing about recursive functions is that the actual code is not incredibly long.
I was pretty happy when I got the initializer to work, although my partner tried it on the input '((0.0)|(0.1))' it kept returning a None on one of the nodes. Just one. We ended up submitting just that though, because it was one of the many examples we tried that didn't work.
It's too bad you didn't figure out what was happening with the weird output, but I'm glad you understood the assignment after speaking with a TA. I also agree that one of the nice things about recursion is that the code is very short. But unfortunately finding the solution can end up taking hours if you're not in the right frame of mind. Nice post!
ReplyDelete