Anyhow, hard work did not go wasted. Two of the questions on the test were almost exactly the same to some of those I went through! One of them was the tedious recursions. Although I might have figured it out anyways, but without the direct solution I would've spent the entire hour working on this problem. I hope no one calls me cheating.. The other was just some simple test cases, I was surprised how it only needed descriptions. Google-ing for explanations of set-up and tear-down functions and memorizing the base format was not pleasant, I actually wanted them on the test.
sidenote: the technique to not lose yourself in a recursion problem is:
- figure out when you want to come out of this loop.(when a value is ###, when you come to the last letter of a string, or finished browsing all occurences of ***)This is the base case.
- write different possibilities that occur in this loop.(like those horoscope tests that direct you to a type of personality after you choose the choices that best fit you)
- ALWAYS TO REMEMBER:in most cases, you have a value or a string or something recorded. You must have it added repetitively when you go through each recursion, or the total result gets lost. It might only record the value from the last loop. The trick is: value += or -= recursion loop.
One interesting question I enjoyed on the test was the first one. I am sure it messed up a lot of us. I feel lucky that I went through a question on stack-overflow.(people ask about computer coding questions on here)
'..... (min, max) for i in range(2:)....'
previously I thought you could only return one single term 'for i in range..', now I know that it would do for set of any number of terms. As long as possible. This was the key to the question.
Then we just had to calculate all the numbers, substitute into the pair of terms, and compare each pair of values....hold on! When we compare a pair of values. e.g. (2,3) and (4,1). How do we tell which one is bigger! Well 2 is smaller than 4 but 3 is bigger than 1, and put it together... my own strategy was just to go with my instincts. Python is not a human-being. It would go through the first variable of each, and it is 2 and 4. So ta-da (4,1) is bigger. No matter it was right or wrong, I would do everything this way to make sure I don't waste too much time one those one-mark questions.(Now I see why our intelligent prof put this as the first question.)
I do think that I've received a decent grade, however I still don't know whereabout to check it.
I do think that I've received a decent grade, however I still don't know whereabout to check it.
No comments:
Post a Comment