- After n folds, there were 2n-1 creases.
- The middle crease always pointed downwards.
- If we folded again, there would be an upward crease to the left of a previous crease, and a downward crease to the right.
As such, we organized the folds into rows with the center intact, such that it looked as follows:
While trying to figure out a way to recreate this in Python code, I figured the best way to do so would be by creating a binary tree where the left child would be "U" for up, and the right child would be "D" for down:
And as such, the output would be the in-order traversal of a tree with a height of n (the number of folds).
To use it, simply type "paper_creases(n)", where n is the number of folds made. I'm sure this code is probably relatively inefficient, and runstyle.py would probably hate it. And just because this SLOG is called peph8:
Curses!
I raise your fold with another fold.
ReplyDelete... So we both lose?
Delete... two games in a row? (double-fold)
DeleteGreat job on finding the pattern, finding a good way to represent it (and actually implementing it)!
ReplyDelete