Sunday, February 16, 2014

week_5 More recursive

This week we've seen more examples in recursive, among which, move_cheeese has been a great help to A1, where we're supposed to do a more complex one with 4 pegs rather than 3.( I decide never to start that late ever again! ) It took me quiet some time to figure out how it works and I found stuffs like recursive sometimes give me a hard time tracing them in my head. I tended to do all the things, i.e. finding best split point and getting all move sequence possible all in one function, which turned out a bad idea and thus I got stuck for, like 2 days, trying to figure out how n-k works for the case where n-k < n. But when I wrote a function computing best k, it's no longer a problem.

 Though I've been learning recursive for the past 2 weeks, it's still kinda challenging to figure out the best code using recursive. What's more, I really don't get it why those codes shown in class always have only one long, subtle sentence for the function body. Whatever, it's really not clear enough for me and I personally prefer not writing a full sentence.

1 comment:

  1. I agree with your point when you say its hard to understand just one line of code.

    In CSC108 (I'm not sure if you took it), they encouraged readability. The professors emphasized that having blocks of clear code was better than one line of confusing code.

    But I suppose as we get into more advanced courses, those one-liners will eventually be more readable for everyone.

    Christina
    http://comp-sci-christie.blogspot.ca/

    ReplyDelete