Stateful rolling paper booklet 


Around here, rolling paper is mainly sold in booklets composed of two stacks of 50 leaves each. Each time you need a leaf, you can choose from which stack to pull one. It works fine, until one of them becomes empty: the remaining one tends to slide under the middle separator, and the leaves become really hard to reach without resorting to destroying the booklet.

The question I asked myself is: "How can I evenly empty both stacks, one leaf at a time, in order to avoid the problem?".


Since I didn't want to have to count how many leaves I already pulled, or remember which stack was the last I pulled from, I devised another strategy: turning the booklet into a gray-coded binary counter!

Gray code is a mirrored binary code, which has the interesting feature that only a single bit has to be flipped at each transition.

On a 2-bit word, it works as following (flipped bit in bold):
0 0
0 1
1 1
1 0
0 0
0 1

From here, I just needed to apply the convention that a leaf pointing down is represented by a "0", and a leaf pointing up is represented by a "1", and I haven't had the need to rip open a rolling paper booklet ever since!

Mandatory picture below.

[ view entry ] ( 11491 views ) permalink

| 1 | 2 | 3 | 4 | Next> Last>>