Tuesday 2 December 2014

Problem Solving - Pattern in the fold of papers.

So the problem was rather straight forward, fold a strip of paper x amount of times from left to right, or right to left but stay consistent, and try to be able to predict the crease pattern at x folds.

I was responsible for taking notes so excuse my atrocious handwriting. So first off we started by folding a paper and recording down the crease patterns for the first 4 folds. First note that I had decided to use U to represent creases that were pointing up and D to represent creases that went down.

So we quickly realized that the previous pattern was the end of the next fold's pattern. (If 2's pattern is UDD, that UDD would appear at the end of 3 folds' pattern.) But after that we did not know how to come up with the crease pattern that came before that.

But after Danny informed us that the middle crease will always be the same and from the hint we were given we tried to find a pattern from the first half of patterns to the second half (Excluding the middle crease which will always remain the same.)

As noted at the bottom of the image, we realized that we can take the letters from the previous pattern, reverse it and then switch the letters (U -> D and if D -> U) and put them at the beginning. By doing this we had created an algorithm to be able to predict the next patterns, as shown by the #5 fold. I had my 2 partners fold it a fifth time while I tried to predict the pattern before they had told me, following the algorithm we assumed was correct. So they read/told me of the pattern and it was exactly what we predicted!

I had written out the algorithm in python but I can't find it right now but if I do find it I'll edit in a link to pastebin here with it. It runs the algorithm described above above using recursion and 2 base cases; the first fold and second fold and from there it's pretty straight forward.

No comments:

Post a Comment