We start by taking a A4 size sheet of paper and stretch it so that you have one end between your left thumb and index finger and the other between your right thumb and forefinger. We then folded the sheet of paper so that the left end is on top of the right end. This process is repeated several times and then the paper is unfolded entirely. Now, we notice that there are creases that either point up or down.
Here is the sequence for the first few folds:
1) D
2) U D D
3) U U D D U D D
4) U U D U U D D D U U D D U D D
5) U U D U U D D U U U D D U D D D U U D U U D D D U U D D U D D
[ U = up, D = down]
We notice that the middle crease is always down and the part after it is exactly the same as the previous sequence. After looking into it further we realize that the first half is the reverse of the previous sequence but with the ups swapped with down and vice versa. This can be nicely summed up by the following recursive statement: return reverse(fold(n-1)) + fold(1) + fold(n - 1)
for n = 2,
reverse(fold (1)) + fold (1) + fold(1) = U + D + D = U D D
We can also observe that the number of creases increases exponentially with the number of folds or to be exact 2^(n) - 1.
Here is the python code:
def fold(n):
base = "D"
if n < 1:
pass
elif n == 1:
return base
else:
return reverse(fold(n-1)) + base + fold(n - 1)
def reverse(str):
reverse = ""
for i in range(len(str)):
reverse += str[len(str) - 1 - i]
swap = ""
for i in range(len(str)):
if reverse[i] == "D":
swap += "U"
elif reverse[i] == "U":
swap += "D"
return swap
Here is the sequence for the first few folds:
1) D
2) U D D
3) U U D D U D D
4) U U D U U D D D U U D D U D D
5) U U D U U D D U U U D D U D D D U U D U U D D D U U D D U D D
[ U = up, D = down]
We notice that the middle crease is always down and the part after it is exactly the same as the previous sequence. After looking into it further we realize that the first half is the reverse of the previous sequence but with the ups swapped with down and vice versa. This can be nicely summed up by the following recursive statement: return reverse(fold(n-1)) + fold(1) + fold(n - 1)
for n = 2,
reverse(fold (1)) + fold (1) + fold(1) = U + D + D = U D D
We can also observe that the number of creases increases exponentially with the number of folds or to be exact 2^(n) - 1.
Here is the python code:
def fold(n):
base = "D"
if n < 1:
pass
elif n == 1:
return base
else:
return reverse(fold(n-1)) + base + fold(n - 1)
def reverse(str):
reverse = ""
for i in range(len(str)):
reverse += str[len(str) - 1 - i]
swap = ""
for i in range(len(str)):
if reverse[i] == "D":
swap += "U"
elif reverse[i] == "U":
swap += "D"
return swap