
Lucky Machine Corp needs your help again.
One of our biggest customers (a crypto-analysis organization that can't
be named) has been using our

The nature of the task only requires tabulating uppercase letters
A–Z.
No lowercase nor any symbols are used. For historical reasons they've
been coding the letters using an old 5-bit code, as shown below,
but they are willing to completely abandon this encoding going
forward, as long as we provide the necessary firmware changes to
the
Once the data from a roll has been read and processed the tape is of no further use and is thrown away. But because of recent budget cuts, they want to know if there's some way to reuse the roll.

(not important—really)
It is a requirement that each
the tape is independent of all the others. Any character can be read from the tape in isolation.
The Punch-22 is a read/write device and can examine the holes currently under the punch head before punching additional holes and advancing to the next row.
An example should give the flavor of the task. The figure shows
an encoding for a four-character alphabet on a
Let's say a B is recorded on the tape during its first use. The machine punches ●. On the second use, if the character to be written is a B, then we leave it as ●; there's no way to use the other code for B (●● ) anyway. If, however, we now need to overwrite an A on top of the B, we can use ●●●. Simlarly a C can now be punched as ● ●, and a D as ●●.
Your task is to come up with a 7-bit code for the symbols
Solution checker in Haskell: here