Monday, September 29, 2014

Week 3

In Friday's class we had an interactive problem solving session where we had to find the pattern generated when we folder a strip of paper. To solve the problem, my partner and I looked at the sample data we had. I saw the length grew at a rate of 2 times the previous length plus 1. My partner quickly found that it was a recursive operation where the previous folder pattern was not only a subset, but ended with the previous set's pattern. Next we looked at the middle item of each sample pattern, and it was the always the same. Lastly I found that the first part of the pattern was a reverse and inverse of the last segment of the pattern. My partner started to code this in Python using strings, but I advised that maybe we should use True and False to represent up and down because in Python to inverse we can just use the keyword not and we can easily do the reverse and inverse operation with the following lines of code:
previousData = [True, True, False, False]
firstPart = [not x for x in reversed(previousData)]

No comments:

Post a Comment