# Coding an Alphabet¶

Given a source alphabet $\{a, b, c\}$, we want to generate a codebook for it--a dictionary of mappings from source symbols to target symbols. For example:

In [1]:
alphabet = set(["a", "b", "c"])
In [9]:
example_codebook = {"a": "0", "b":"10", "c":"11"}
In [11]:
def encode(text):
output = []
for x in text:
output.append(example_codebook[x])
return "".join(output)
In [12]:
encode("abcabc")
Out[12]:
'0101101011'

or....

In [13]:
encode("aaaa")
Out[13]:
'0000'

# Checking if a code is prefix-free¶

A code is prefix-free iff $\forall (x \in \texttt{codebook})\forall (y \in \texttt{codebook})\; x \neq y \rightarrow x\text{ is not a prefix of }y$.

In [16]:
def is_prefix_free(codebook):
# Compare all
for i in range(len(codebook)):
for j in range(len(codebook)):
if i != j and codebook[i].startswith(codebook[j]):
return False
return True
In [18]:
example_codebook, is_prefix_free(list(example_codebook.values()))
Out[18]:
({'a': '0', 'b': '10', 'c': '11'}, True)

# Generating all binary strings¶

To generate all binary strings, we recursively choose the first character:

0 0 0 1 1 0 1 1 0 0 1 1 0 1

In [19]:
def binary_strings(length):
if length == 0:
# There is one string of length zero!
# Otherwise, our recursive function will return 0 strings for every length.
return [""]
# Try prepending "0" and "1"
return ["0" + x for x in binary_strings(length - 1)] + ["1" + x for x in binary_strings(length - 1)]
In [20]:
binary_strings(0)
Out[20]:
['']
In [21]:
binary_strings(1)
Out[21]:
['0', '1']
In [22]:
binary_strings(4)
Out[22]:
['0000',
'0001',
'0010',
'0011',
'0100',
'0101',
'0110',
'0111',
'1000',
'1001',
'1010',
'1011',
'1100',
'1101',
'1110',
'1111']

# Generating all codebooks from a set of possible codes¶

In [23]:
possible_codes = binary_strings(1) + binary_strings(2) + binary_strings(3)
In [24]:
def all_codebooks(remaining_codes, remaining_length):
if remaining_length == 0:
# There is a single codebook with nothing in it
return [[]]
books = []
# For each possible "first" target symbol in the codebook...
for start in range(len(remaining_codes)):
# Try it...
first = remaining_codes[start]
# And cut out everything before it...
remaining_possibilities = remaining_codes[start + 1:]
# Make all combinations with that first symbol and the "remaining possibilities"
books += [[first] + x for x in all_codebooks(remaining_codes, remaining_length - 1)]
return books
In [27]:
all_codebooks(possible_codes, 3)
Out[27]:
[['0', '0', '0'],
['0', '0', '1'],
['0', '0', '00'],
['0', '0', '01'],
['0', '0', '10'],
['0', '0', '11'],
['0', '0', '000'],
['0', '0', '001'],
['0', '0', '010'],
['0', '0', '011'],
['0', '0', '100'],
['0', '0', '101'],
['0', '0', '110'],
['0', '0', '111'],
['0', '1', '0'],
['0', '1', '1'],
['0', '1', '00'],
['0', '1', '01'],
['0', '1', '10'],
['0', '1', '11'],
['0', '1', '000'],
['0', '1', '001'],
['0', '1', '010'],
['0', '1', '011'],
['0', '1', '100'],
['0', '1', '101'],
['0', '1', '110'],
['0', '1', '111'],
['0', '00', '0'],
['0', '00', '1'],
['0', '00', '00'],
['0', '00', '01'],
['0', '00', '10'],
['0', '00', '11'],
['0', '00', '000'],
['0', '00', '001'],
['0', '00', '010'],
['0', '00', '011'],
['0', '00', '100'],
['0', '00', '101'],
['0', '00', '110'],
['0', '00', '111'],
['0', '01', '0'],
['0', '01', '1'],
['0', '01', '00'],
['0', '01', '01'],
['0', '01', '10'],
['0', '01', '11'],
['0', '01', '000'],
['0', '01', '001'],
['0', '01', '010'],
['0', '01', '011'],
['0', '01', '100'],
['0', '01', '101'],
['0', '01', '110'],
['0', '01', '111'],
['0', '10', '0'],
['0', '10', '1'],
['0', '10', '00'],
['0', '10', '01'],
['0', '10', '10'],
['0', '10', '11'],
['0', '10', '000'],
['0', '10', '001'],
['0', '10', '010'],
['0', '10', '011'],
['0', '10', '100'],
['0', '10', '101'],
['0', '10', '110'],
['0', '10', '111'],
['0', '11', '0'],
['0', '11', '1'],
['0', '11', '00'],
['0', '11', '01'],
['0', '11', '10'],
['0', '11', '11'],
['0', '11', '000'],
['0', '11', '001'],
['0', '11', '010'],
['0', '11', '011'],
['0', '11', '100'],
['0', '11', '101'],
['0', '11', '110'],
['0', '11', '111'],
['0', '000', '0'],
['0', '000', '1'],
['0', '000', '00'],
['0', '000', '01'],
['0', '000', '10'],
['0', '000', '11'],
['0', '000', '000'],
['0', '000', '001'],
['0', '000', '010'],
['0', '000', '011'],
['0', '000', '100'],
['0', '000', '101'],
['0', '000', '110'],
['0', '000', '111'],
['0', '001', '0'],
['0', '001', '1'],
['0', '001', '00'],
['0', '001', '01'],
['0', '001', '10'],
['0', '001', '11'],
['0', '001', '000'],
['0', '001', '001'],
['0', '001', '010'],
['0', '001', '011'],
['0', '001', '100'],
['0', '001', '101'],
['0', '001', '110'],
['0', '001', '111'],
['0', '010', '0'],
['0', '010', '1'],
['0', '010', '00'],
['0', '010', '01'],
['0', '010', '10'],
['0', '010', '11'],
['0', '010', '000'],
['0', '010', '001'],
['0', '010', '010'],
['0', '010', '011'],
['0', '010', '100'],
['0', '010', '101'],
['0', '010', '110'],
['0', '010', '111'],
['0', '011', '0'],
['0', '011', '1'],
['0', '011', '00'],
['0', '011', '01'],
['0', '011', '10'],
['0', '011', '11'],
['0', '011', '000'],
['0', '011', '001'],
['0', '011', '010'],
['0', '011', '011'],
['0', '011', '100'],
['0', '011', '101'],
['0', '011', '110'],
['0', '011', '111'],
['0', '100', '0'],
['0', '100', '1'],
['0', '100', '00'],
['0', '100', '01'],
['0', '100', '10'],
['0', '100', '11'],
['0', '100', '000'],
['0', '100', '001'],
['0', '100', '010'],
['0', '100', '011'],
['0', '100', '100'],
['0', '100', '101'],
['0', '100', '110'],
['0', '100', '111'],
['0', '101', '0'],
['0', '101', '1'],
['0', '101', '00'],
['0', '101', '01'],
['0', '101', '10'],
['0', '101', '11'],
['0', '101', '000'],
['0', '101', '001'],
['0', '101', '010'],
['0', '101', '011'],
['0', '101', '100'],
['0', '101', '101'],
['0', '101', '110'],
['0', '101', '111'],
['0', '110', '0'],
['0', '110', '1'],
['0', '110', '00'],
['0', '110', '01'],
['0', '110', '10'],
['0', '110', '11'],
['0', '110', '000'],
['0', '110', '001'],
['0', '110', '010'],
['0', '110', '011'],
['0', '110', '100'],
['0', '110', '101'],
['0', '110', '110'],
['0', '110', '111'],
['0', '111', '0'],
['0', '111', '1'],
['0', '111', '00'],
['0', '111', '01'],
['0', '111', '10'],
['0', '111', '11'],
['0', '111', '000'],
['0', '111', '001'],
['0', '111', '010'],
['0', '111', '011'],
['0', '111', '100'],
['0', '111', '101'],
['0', '111', '110'],
['0', '111', '111'],
['1', '0', '0'],
['1', '0', '1'],
['1', '0', '00'],
['1', '0', '01'],
['1', '0', '10'],
['1', '0', '11'],
['1', '0', '000'],
['1', '0', '001'],
['1', '0', '010'],
['1', '0', '011'],
['1', '0', '100'],
['1', '0', '101'],
['1', '0', '110'],
['1', '0', '111'],
['1', '1', '0'],
['1', '1', '1'],
['1', '1', '00'],
['1', '1', '01'],
['1', '1', '10'],
['1', '1', '11'],
['1', '1', '000'],
['1', '1', '001'],
['1', '1', '010'],
['1', '1', '011'],
['1', '1', '100'],
['1', '1', '101'],
['1', '1', '110'],
['1', '1', '111'],
['1', '00', '0'],
['1', '00', '1'],
['1', '00', '00'],
['1', '00', '01'],
['1', '00', '10'],
['1', '00', '11'],
['1', '00', '000'],
['1', '00', '001'],
['1', '00', '010'],
['1', '00', '011'],
['1', '00', '100'],
['1', '00', '101'],
['1', '00', '110'],
['1', '00', '111'],
['1', '01', '0'],
['1', '01', '1'],
['1', '01', '00'],
['1', '01', '01'],
['1', '01', '10'],
['1', '01', '11'],
['1', '01', '000'],
['1', '01', '001'],
['1', '01', '010'],
['1', '01', '011'],
['1', '01', '100'],
['1', '01', '101'],
['1', '01', '110'],
['1', '01', '111'],
['1', '10', '0'],
['1', '10', '1'],
['1', '10', '00'],
['1', '10', '01'],
['1', '10', '10'],
['1', '10', '11'],
['1', '10', '000'],
['1', '10', '001'],
['1', '10', '010'],
['1', '10', '011'],
['1', '10', '100'],
['1', '10', '101'],
['1', '10', '110'],
['1', '10', '111'],
['1', '11', '0'],
['1', '11', '1'],
['1', '11', '00'],
['1', '11', '01'],
['1', '11', '10'],
['1', '11', '11'],
['1', '11', '000'],
['1', '11', '001'],
['1', '11', '010'],
['1', '11', '011'],
['1', '11', '100'],
['1', '11', '101'],
['1', '11', '110'],
['1', '11', '111'],
['1', '000', '0'],
['1', '000', '1'],
['1', '000', '00'],
['1', '000', '01'],
['1', '000', '10'],
['1', '000', '11'],
['1', '000', '000'],
['1', '000', '001'],
['1', '000', '010'],
['1', '000', '011'],
['1', '000', '100'],
['1', '000', '101'],
['1', '000', '110'],
['1', '000', '111'],
['1', '001', '0'],
['1', '001', '1'],
['1', '001', '00'],
['1', '001', '01'],
['1', '001', '10'],
['1', '001', '11'],
['1', '001', '000'],
['1', '001', '001'],
['1', '001', '010'],
['1', '001', '011'],
['1', '001', '100'],
['1', '001', '101'],
['1', '001', '110'],
['1', '001', '111'],
['1', '010', '0'],
['1', '010', '1'],
['1', '010', '00'],
['1', '010', '01'],
['1', '010', '10'],
['1', '010', '11'],
['1', '010', '000'],
['1', '010', '001'],
['1', '010', '010'],
['1', '010', '011'],
['1', '010', '100'],
['1', '010', '101'],
['1', '010', '110'],
['1', '010', '111'],
['1', '011', '0'],
['1', '011', '1'],
['1', '011', '00'],
['1', '011', '01'],
['1', '011', '10'],
['1', '011', '11'],
['1', '011', '000'],
['1', '011', '001'],
['1', '011', '010'],
['1', '011', '011'],
['1', '011', '100'],
['1', '011', '101'],
['1', '011', '110'],
['1', '011', '111'],
['1', '100', '0'],
['1', '100', '1'],
['1', '100', '00'],
['1', '100', '01'],
['1', '100', '10'],
['1', '100', '11'],
['1', '100', '000'],
['1', '100', '001'],
['1', '100', '010'],
['1', '100', '011'],
['1', '100', '100'],
['1', '100', '101'],
['1', '100', '110'],
['1', '100', '111'],
['1', '101', '0'],
['1', '101', '1'],
['1', '101', '00'],
['1', '101', '01'],
['1', '101', '10'],
['1', '101', '11'],
['1', '101', '000'],
['1', '101', '001'],
['1', '101', '010'],
['1', '101', '011'],
['1', '101', '100'],
['1', '101', '101'],
['1', '101', '110'],
['1', '101', '111'],
['1', '110', '0'],
['1', '110', '1'],
['1', '110', '00'],
['1', '110', '01'],
['1', '110', '10'],
['1', '110', '11'],
['1', '110', '000'],
['1', '110', '001'],
['1', '110', '010'],
['1', '110', '011'],
['1', '110', '100'],
['1', '110', '101'],
['1', '110', '110'],
['1', '110', '111'],
['1', '111', '0'],
['1', '111', '1'],
['1', '111', '00'],
['1', '111', '01'],
['1', '111', '10'],
['1', '111', '11'],
['1', '111', '000'],
['1', '111', '001'],
['1', '111', '010'],
['1', '111', '011'],
['1', '111', '100'],
['1', '111', '101'],
['1', '111', '110'],
['1', '111', '111'],
['00', '0', '0'],
['00', '0', '1'],
['00', '0', '00'],
['00', '0', '01'],
['00', '0', '10'],
['00', '0', '11'],
['00', '0', '000'],
['00', '0', '001'],
['00', '0', '010'],
['00', '0', '011'],
['00', '0', '100'],
['00', '0', '101'],
['00', '0', '110'],
['00', '0', '111'],
['00', '1', '0'],
['00', '1', '1'],
['00', '1', '00'],
['00', '1', '01'],
['00', '1', '10'],
['00', '1', '11'],
['00', '1', '000'],
['00', '1', '001'],
['00', '1', '010'],
['00', '1', '011'],
['00', '1', '100'],
['00', '1', '101'],
['00', '1', '110'],
['00', '1', '111'],
['00', '00', '0'],
['00', '00', '1'],
['00', '00', '00'],
['00', '00', '01'],
['00', '00', '10'],
['00', '00', '11'],
['00', '00', '000'],
['00', '00', '001'],
['00', '00', '010'],
['00', '00', '011'],
['00', '00', '100'],
['00', '00', '101'],
['00', '00', '110'],
['00', '00', '111'],
['00', '01', '0'],
['00', '01', '1'],
['00', '01', '00'],
['00', '01', '01'],
['00', '01', '10'],
['00', '01', '11'],
['00', '01', '000'],
['00', '01', '001'],
['00', '01', '010'],
['00', '01', '011'],
['00', '01', '100'],
['00', '01', '101'],
['00', '01', '110'],
['00', '01', '111'],
['00', '10', '0'],
['00', '10', '1'],
['00', '10', '00'],
['00', '10', '01'],
['00', '10', '10'],
['00', '10', '11'],
['00', '10', '000'],
['00', '10', '001'],
['00', '10', '010'],
['00', '10', '011'],
['00', '10', '100'],
['00', '10', '101'],
['00', '10', '110'],
['00', '10', '111'],
['00', '11', '0'],
['00', '11', '1'],
['00', '11', '00'],
['00', '11', '01'],
['00', '11', '10'],
['00', '11', '11'],
['00', '11', '000'],
['00', '11', '001'],
['00', '11', '010'],
['00', '11', '011'],
['00', '11', '100'],
['00', '11', '101'],
['00', '11', '110'],
['00', '11', '111'],
['00', '000', '0'],
['00', '000', '1'],
['00', '000', '00'],
['00', '000', '01'],
['00', '000', '10'],
['00', '000', '11'],
['00', '000', '000'],
['00', '000', '001'],
['00', '000', '010'],
['00', '000', '011'],
['00', '000', '100'],
['00', '000', '101'],
['00', '000', '110'],
['00', '000', '111'],
['00', '001', '0'],
['00', '001', '1'],
['00', '001', '00'],
['00', '001', '01'],
['00', '001', '10'],
['00', '001', '11'],
['00', '001', '000'],
['00', '001', '001'],
['00', '001', '010'],
['00', '001', '011'],
['00', '001', '100'],
['00', '001', '101'],
['00', '001', '110'],
['00', '001', '111'],
['00', '010', '0'],
['00', '010', '1'],
['00', '010', '00'],
['00', '010', '01'],
['00', '010', '10'],
['00', '010', '11'],
['00', '010', '000'],
['00', '010', '001'],
['00', '010', '010'],
['00', '010', '011'],
['00', '010', '100'],
['00', '010', '101'],
['00', '010', '110'],
['00', '010', '111'],
['00', '011', '0'],
['00', '011', '1'],
['00', '011', '00'],
['00', '011', '01'],
['00', '011', '10'],
['00', '011', '11'],
['00', '011', '000'],
['00', '011', '001'],
['00', '011', '010'],
['00', '011', '011'],
['00', '011', '100'],
['00', '011', '101'],
['00', '011', '110'],
['00', '011', '111'],
['00', '100', '0'],
['00', '100', '1'],
['00', '100', '00'],
['00', '100', '01'],
['00', '100', '10'],
['00', '100', '11'],
['00', '100', '000'],
['00', '100', '001'],
['00', '100', '010'],
['00', '100', '011'],
['00', '100', '100'],
['00', '100', '101'],
['00', '100', '110'],
['00', '100', '111'],
['00', '101', '0'],
['00', '101', '1'],
['00', '101', '00'],
['00', '101', '01'],
['00', '101', '10'],
['00', '101', '11'],
['00', '101', '000'],
['00', '101', '001'],
['00', '101', '010'],
['00', '101', '011'],
['00', '101', '100'],
['00', '101', '101'],
['00', '101', '110'],
['00', '101', '111'],
['00', '110', '0'],
['00', '110', '1'],
['00', '110', '00'],
['00', '110', '01'],
['00', '110', '10'],
['00', '110', '11'],
['00', '110', '000'],
['00', '110', '001'],
['00', '110', '010'],
['00', '110', '011'],
['00', '110', '100'],
['00', '110', '101'],
['00', '110', '110'],
['00', '110', '111'],
['00', '111', '0'],
['00', '111', '1'],
['00', '111', '00'],
['00', '111', '01'],
['00', '111', '10'],
['00', '111', '11'],
['00', '111', '000'],
['00', '111', '001'],
['00', '111', '010'],
['00', '111', '011'],
['00', '111', '100'],
['00', '111', '101'],
['00', '111', '110'],
['00', '111', '111'],
['01', '0', '0'],
['01', '0', '1'],
['01', '0', '00'],
['01', '0', '01'],
['01', '0', '10'],
['01', '0', '11'],
['01', '0', '000'],
['01', '0', '001'],
['01', '0', '010'],
['01', '0', '011'],
['01', '0', '100'],
['01', '0', '101'],
['01', '0', '110'],
['01', '0', '111'],
['01', '1', '0'],
['01', '1', '1'],
['01', '1', '00'],
['01', '1', '01'],
['01', '1', '10'],
['01', '1', '11'],
['01', '1', '000'],
['01', '1', '001'],
['01', '1', '010'],
['01', '1', '011'],
['01', '1', '100'],
['01', '1', '101'],
['01', '1', '110'],
['01', '1', '111'],
['01', '00', '0'],
['01', '00', '1'],
['01', '00', '00'],
['01', '00', '01'],
['01', '00', '10'],
['01', '00', '11'],
['01', '00', '000'],
['01', '00', '001'],
['01', '00', '010'],
['01', '00', '011'],
['01', '00', '100'],
['01', '00', '101'],
['01', '00', '110'],
['01', '00', '111'],
['01', '01', '0'],
['01', '01', '1'],
['01', '01', '00'],
['01', '01', '01'],
['01', '01', '10'],
['01', '01', '11'],
['01', '01', '000'],
['01', '01', '001'],
['01', '01', '010'],
['01', '01', '011'],
['01', '01', '100'],
['01', '01', '101'],
['01', '01', '110'],
['01', '01', '111'],
['01', '10', '0'],
['01', '10', '1'],
['01', '10', '00'],
['01', '10', '01'],
['01', '10', '10'],
['01', '10', '11'],
['01', '10', '000'],
['01', '10', '001'],
['01', '10', '010'],
['01', '10', '011'],
['01', '10', '100'],
['01', '10', '101'],
['01', '10', '110'],
['01', '10', '111'],
['01', '11', '0'],
['01', '11', '1'],
['01', '11', '00'],
['01', '11', '01'],
['01', '11', '10'],
['01', '11', '11'],
['01', '11', '000'],
['01', '11', '001'],
['01', '11', '010'],
['01', '11', '011'],
['01', '11', '100'],
['01', '11', '101'],
['01', '11', '110'],
['01', '11', '111'],
['01', '000', '0'],
['01', '000', '1'],
['01', '000', '00'],
['01', '000', '01'],
['01', '000', '10'],
['01', '000', '11'],
['01', '000', '000'],
['01', '000', '001'],
['01', '000', '010'],
['01', '000', '011'],
['01', '000', '100'],
['01', '000', '101'],
['01', '000', '110'],
['01', '000', '111'],
['01', '001', '0'],
['01', '001', '1'],
['01', '001', '00'],
['01', '001', '01'],
['01', '001', '10'],
['01', '001', '11'],
['01', '001', '000'],
['01', '001', '001'],
['01', '001', '010'],
['01', '001', '011'],
['01', '001', '100'],
['01', '001', '101'],
['01', '001', '110'],
['01', '001', '111'],
['01', '010', '0'],
['01', '010', '1'],
['01', '010', '00'],
['01', '010', '01'],
['01', '010', '10'],
['01', '010', '11'],
['01', '010', '000'],
['01', '010', '001'],
['01', '010', '010'],
['01', '010', '011'],
['01', '010', '100'],
['01', '010', '101'],
['01', '010', '110'],
['01', '010', '111'],
['01', '011', '0'],
['01', '011', '1'],
['01', '011', '00'],
['01', '011', '01'],
['01', '011', '10'],
['01', '011', '11'],
['01', '011', '000'],
['01', '011', '001'],
['01', '011', '010'],
['01', '011', '011'],
['01', '011', '100'],
['01', '011', '101'],
['01', '011', '110'],
['01', '011', '111'],
['01', '100', '0'],
['01', '100', '1'],
['01', '100', '00'],
['01', '100', '01'],
['01', '100', '10'],
['01', '100', '11'],
['01', '100', '000'],
['01', '100', '001'],
['01', '100', '010'],
['01', '100', '011'],
['01', '100', '100'],
['01', '100', '101'],
['01', '100', '110'],
['01', '100', '111'],
['01', '101', '0'],
['01', '101', '1'],
['01', '101', '00'],
['01', '101', '01'],
['01', '101', '10'],
['01', '101', '11'],
['01', '101', '000'],
['01', '101', '001'],
['01', '101', '010'],
['01', '101', '011'],
['01', '101', '100'],
['01', '101', '101'],
['01', '101', '110'],
['01', '101', '111'],
['01', '110', '0'],
['01', '110', '1'],
['01', '110', '00'],
['01', '110', '01'],
['01', '110', '10'],
['01', '110', '11'],
['01', '110', '000'],
['01', '110', '001'],
['01', '110', '010'],
['01', '110', '011'],
['01', '110', '100'],
['01', '110', '101'],
['01', '110', '110'],
['01', '110', '111'],
['01', '111', '0'],
['01', '111', '1'],
['01', '111', '00'],
['01', '111', '01'],
['01', '111', '10'],
['01', '111', '11'],
['01', '111', '000'],
['01', '111', '001'],
['01', '111', '010'],
['01', '111', '011'],
['01', '111', '100'],
['01', '111', '101'],
['01', '111', '110'],
['01', '111', '111'],
['10', '0', '0'],
['10', '0', '1'],
['10', '0', '00'],
['10', '0', '01'],
['10', '0', '10'],
['10', '0', '11'],
['10', '0', '000'],
['10', '0', '001'],
['10', '0', '010'],
['10', '0', '011'],
['10', '0', '100'],
['10', '0', '101'],
['10', '0', '110'],
['10', '0', '111'],
['10', '1', '0'],
['10', '1', '1'],
['10', '1', '00'],
['10', '1', '01'],
['10', '1', '10'],
['10', '1', '11'],
['10', '1', '000'],
['10', '1', '001'],
['10', '1', '010'],
['10', '1', '011'],
['10', '1', '100'],
['10', '1', '101'],
['10', '1', '110'],
['10', '1', '111'],
['10', '00', '0'],
['10', '00', '1'],
['10', '00', '00'],
['10', '00', '01'],
['10', '00', '10'],
['10', '00', '11'],
['10', '00', '000'],
['10', '00', '001'],
['10', '00', '010'],
['10', '00', '011'],
['10', '00', '100'],
['10', '00', '101'],
['10', '00', '110'],
['10', '00', '111'],
['10', '01', '0'],
['10', '01', '1'],
['10', '01', '00'],
['10', '01', '01'],
['10', '01', '10'],
['10', '01', '11'],
['10', '01', '000'],
['10', '01', '001'],
['10', '01', '010'],
['10', '01', '011'],
['10', '01', '100'],
['10', '01', '101'],
['10', '01', '110'],
['10', '01', '111'],
['10', '10', '0'],
['10', '10', '1'],
['10', '10', '00'],
['10', '10', '01'],
['10', '10', '10'],
['10', '10', '11'],
['10', '10', '000'],
['10', '10', '001'],
['10', '10', '010'],
['10', '10', '011'],
['10', '10', '100'],
['10', '10', '101'],
['10', '10', '110'],
['10', '10', '111'],
['10', '11', '0'],
['10', '11', '1'],
['10', '11', '00'],
['10', '11', '01'],
['10', '11', '10'],
['10', '11', '11'],
['10', '11', '000'],
['10', '11', '001'],
['10', '11', '010'],
['10', '11', '011'],
['10', '11', '100'],
['10', '11', '101'],
['10', '11', '110'],
['10', '11', '111'],
['10', '000', '0'],
['10', '000', '1'],
['10', '000', '00'],
['10', '000', '01'],
['10', '000', '10'],
['10', '000', '11'],
['10', '000', '000'],
['10', '000', '001'],
['10', '000', '010'],
['10', '000', '011'],
['10', '000', '100'],
['10', '000', '101'],
['10', '000', '110'],
['10', '000', '111'],
['10', '001', '0'],
['10', '001', '1'],
['10', '001', '00'],
['10', '001', '01'],
['10', '001', '10'],
['10', '001', '11'],
['10', '001', '000'],
['10', '001', '001'],
['10', '001', '010'],
['10', '001', '011'],
['10', '001', '100'],
['10', '001', '101'],
['10', '001', '110'],
['10', '001', '111'],
['10', '010', '0'],
['10', '010', '1'],
['10', '010', '00'],
['10', '010', '01'],
['10', '010', '10'],
['10', '010', '11'],
['10', '010', '000'],
['10', '010', '001'],
['10', '010', '010'],
['10', '010', '011'],
['10', '010', '100'],
['10', '010', '101'],
['10', '010', '110'],
['10', '010', '111'],
['10', '011', '0'],
['10', '011', '1'],
['10', '011', '00'],
['10', '011', '01'],
['10', '011', '10'],
['10', '011', '11'],
['10', '011', '000'],
['10', '011', '001'],
['10', '011', '010'],
['10', '011', '011'],
['10', '011', '100'],
['10', '011', '101'],
['10', '011', '110'],
['10', '011', '111'],
['10', '100', '0'],
['10', '100', '1'],
['10', '100', '00'],
['10', '100', '01'],
['10', '100', '10'],
['10', '100', '11'],
['10', '100', '000'],
['10', '100', '001'],
['10', '100', '010'],
['10', '100', '011'],
['10', '100', '100'],
['10', '100', '101'],
['10', '100', '110'],
['10', '100', '111'],
['10', '101', '0'],
['10', '101', '1'],
['10', '101', '00'],
['10', '101', '01'],
['10', '101', '10'],
['10', '101', '11'],
['10', '101', '000'],
['10', '101', '001'],
['10', '101', '010'],
['10', '101', '011'],
['10', '101', '100'],
['10', '101', '101'],
['10', '101', '110'],
['10', '101', '111'],
['10', '110', '0'],
['10', '110', '1'],
['10', '110', '00'],
['10', '110', '01'],
['10', '110', '10'],
['10', '110', '11'],
['10', '110', '000'],
['10', '110', '001'],
['10', '110', '010'],
['10', '110', '011'],
['10', '110', '100'],
['10', '110', '101'],
['10', '110', '110'],
['10', '110', '111'],
['10', '111', '0'],
['10', '111', '1'],
['10', '111', '00'],
['10', '111', '01'],
['10', '111', '10'],
['10', '111', '11'],
['10', '111', '000'],
['10', '111', '001'],
['10', '111', '010'],
['10', '111', '011'],
['10', '111', '100'],
['10', '111', '101'],
['10', '111', '110'],
['10', '111', '111'],
['11', '0', '0'],
['11', '0', '1'],
['11', '0', '00'],
['11', '0', '01'],
['11', '0', '10'],
['11', '0', '11'],
['11', '0', '000'],
['11', '0', '001'],
['11', '0', '010'],
['11', '0', '011'],
['11', '0', '100'],
['11', '0', '101'],
['11', '0', '110'],
['11', '0', '111'],
['11', '1', '0'],
['11', '1', '1'],
['11', '1', '00'],
['11', '1', '01'],
['11', '1', '10'],
['11', '1', '11'],
...]
In [28]:
prefix_free_codebooks = [x for x in all_codebooks(possible_codes, 3) if is_prefix_free(x)]
In [29]:
prefix_free_codebooks
Out[29]:
[['0', '10', '11'],
['0', '10', '110'],
['0', '10', '111'],
['0', '11', '10'],
['0', '11', '100'],
['0', '11', '101'],
['0', '100', '11'],
['0', '100', '101'],
['0', '100', '110'],
['0', '100', '111'],
['0', '101', '11'],
['0', '101', '100'],
['0', '101', '110'],
['0', '101', '111'],
['0', '110', '10'],
['0', '110', '100'],
['0', '110', '101'],
['0', '110', '111'],
['0', '111', '10'],
['0', '111', '100'],
['0', '111', '101'],
['0', '111', '110'],
['1', '00', '01'],
['1', '00', '010'],
['1', '00', '011'],
['1', '01', '00'],
['1', '01', '000'],
['1', '01', '001'],
['1', '000', '01'],
['1', '000', '001'],
['1', '000', '010'],
['1', '000', '011'],
['1', '001', '01'],
['1', '001', '000'],
['1', '001', '010'],
['1', '001', '011'],
['1', '010', '00'],
['1', '010', '000'],
['1', '010', '001'],
['1', '010', '011'],
['1', '011', '00'],
['1', '011', '000'],
['1', '011', '001'],
['1', '011', '010'],
['00', '1', '01'],
['00', '1', '010'],
['00', '1', '011'],
['00', '01', '1'],
['00', '01', '10'],
['00', '01', '11'],
['00', '01', '100'],
['00', '01', '101'],
['00', '01', '110'],
['00', '01', '111'],
['00', '10', '01'],
['00', '10', '11'],
['00', '10', '010'],
['00', '10', '011'],
['00', '10', '110'],
['00', '10', '111'],
['00', '11', '01'],
['00', '11', '10'],
['00', '11', '010'],
['00', '11', '011'],
['00', '11', '100'],
['00', '11', '101'],
['00', '010', '1'],
['00', '010', '10'],
['00', '010', '11'],
['00', '010', '011'],
['00', '010', '100'],
['00', '010', '101'],
['00', '010', '110'],
['00', '010', '111'],
['00', '011', '1'],
['00', '011', '10'],
['00', '011', '11'],
['00', '011', '010'],
['00', '011', '100'],
['00', '011', '101'],
['00', '011', '110'],
['00', '011', '111'],
['00', '100', '01'],
['00', '100', '11'],
['00', '100', '010'],
['00', '100', '011'],
['00', '100', '101'],
['00', '100', '110'],
['00', '100', '111'],
['00', '101', '01'],
['00', '101', '11'],
['00', '101', '010'],
['00', '101', '011'],
['00', '101', '100'],
['00', '101', '110'],
['00', '101', '111'],
['00', '110', '01'],
['00', '110', '10'],
['00', '110', '010'],
['00', '110', '011'],
['00', '110', '100'],
['00', '110', '101'],
['00', '110', '111'],
['00', '111', '01'],
['00', '111', '10'],
['00', '111', '010'],
['00', '111', '011'],
['00', '111', '100'],
['00', '111', '101'],
['00', '111', '110'],
['01', '1', '00'],
['01', '1', '000'],
['01', '1', '001'],
['01', '00', '1'],
['01', '00', '10'],
['01', '00', '11'],
['01', '00', '100'],
['01', '00', '101'],
['01', '00', '110'],
['01', '00', '111'],
['01', '10', '00'],
['01', '10', '11'],
['01', '10', '000'],
['01', '10', '001'],
['01', '10', '110'],
['01', '10', '111'],
['01', '11', '00'],
['01', '11', '10'],
['01', '11', '000'],
['01', '11', '001'],
['01', '11', '100'],
['01', '11', '101'],
['01', '000', '1'],
['01', '000', '10'],
['01', '000', '11'],
['01', '000', '001'],
['01', '000', '100'],
['01', '000', '101'],
['01', '000', '110'],
['01', '000', '111'],
['01', '001', '1'],
['01', '001', '10'],
['01', '001', '11'],
['01', '001', '000'],
['01', '001', '100'],
['01', '001', '101'],
['01', '001', '110'],
['01', '001', '111'],
['01', '100', '00'],
['01', '100', '11'],
['01', '100', '000'],
['01', '100', '001'],
['01', '100', '101'],
['01', '100', '110'],
['01', '100', '111'],
['01', '101', '00'],
['01', '101', '11'],
['01', '101', '000'],
['01', '101', '001'],
['01', '101', '100'],
['01', '101', '110'],
['01', '101', '111'],
['01', '110', '00'],
['01', '110', '10'],
['01', '110', '000'],
['01', '110', '001'],
['01', '110', '100'],
['01', '110', '101'],
['01', '110', '111'],
['01', '111', '00'],
['01', '111', '10'],
['01', '111', '000'],
['01', '111', '001'],
['01', '111', '100'],
['01', '111', '101'],
['01', '111', '110'],
['10', '0', '11'],
['10', '0', '110'],
['10', '0', '111'],
['10', '00', '01'],
['10', '00', '11'],
['10', '00', '010'],
['10', '00', '011'],
['10', '00', '110'],
['10', '00', '111'],
['10', '01', '00'],
['10', '01', '11'],
['10', '01', '000'],
['10', '01', '001'],
['10', '01', '110'],
['10', '01', '111'],
['10', '11', '0'],
['10', '11', '00'],
['10', '11', '01'],
['10', '11', '000'],
['10', '11', '001'],
['10', '11', '010'],
['10', '11', '011'],
['10', '000', '01'],
['10', '000', '11'],
['10', '000', '001'],
['10', '000', '010'],
['10', '000', '011'],
['10', '000', '110'],
['10', '000', '111'],
['10', '001', '01'],
['10', '001', '11'],
['10', '001', '000'],
['10', '001', '010'],
['10', '001', '011'],
['10', '001', '110'],
['10', '001', '111'],
['10', '010', '00'],
['10', '010', '11'],
['10', '010', '000'],
['10', '010', '001'],
['10', '010', '011'],
['10', '010', '110'],
['10', '010', '111'],
['10', '011', '00'],
['10', '011', '11'],
['10', '011', '000'],
['10', '011', '001'],
['10', '011', '010'],
['10', '011', '110'],
['10', '011', '111'],
['10', '110', '0'],
['10', '110', '00'],
['10', '110', '01'],
['10', '110', '000'],
['10', '110', '001'],
['10', '110', '010'],
['10', '110', '011'],
['10', '110', '111'],
['10', '111', '0'],
['10', '111', '00'],
['10', '111', '01'],
['10', '111', '000'],
['10', '111', '001'],
['10', '111', '010'],
['10', '111', '011'],
['10', '111', '110'],
['11', '0', '10'],
['11', '0', '100'],
['11', '0', '101'],
['11', '00', '01'],
['11', '00', '10'],
['11', '00', '010'],
['11', '00', '011'],
['11', '00', '100'],
['11', '00', '101'],
['11', '01', '00'],
['11', '01', '10'],
['11', '01', '000'],
['11', '01', '001'],
['11', '01', '100'],
['11', '01', '101'],
['11', '10', '0'],
['11', '10', '00'],
['11', '10', '01'],
['11', '10', '000'],
['11', '10', '001'],
['11', '10', '010'],
['11', '10', '011'],
['11', '000', '01'],
['11', '000', '10'],
['11', '000', '001'],
['11', '000', '010'],
['11', '000', '011'],
['11', '000', '100'],
['11', '000', '101'],
['11', '001', '01'],
['11', '001', '10'],
['11', '001', '000'],
['11', '001', '010'],
['11', '001', '011'],
['11', '001', '100'],
['11', '001', '101'],
['11', '010', '00'],
['11', '010', '10'],
['11', '010', '000'],
['11', '010', '001'],
['11', '010', '011'],
['11', '010', '100'],
['11', '010', '101'],
['11', '011', '00'],
['11', '011', '10'],
['11', '011', '000'],
['11', '011', '001'],
['11', '011', '010'],
['11', '011', '100'],
['11', '011', '101'],
['11', '100', '0'],
['11', '100', '00'],
['11', '100', '01'],
['11', '100', '000'],
['11', '100', '001'],
['11', '100', '010'],
['11', '100', '011'],
['11', '100', '101'],
['11', '101', '0'],
['11', '101', '00'],
['11', '101', '01'],
['11', '101', '000'],
['11', '101', '001'],
['11', '101', '010'],
['11', '101', '011'],
['11', '101', '100'],
['000', '1', '01'],
['000', '1', '001'],
['000', '1', '010'],
['000', '1', '011'],
['000', '01', '1'],
['000', '01', '10'],
['000', '01', '11'],
['000', '01', '001'],
['000', '01', '100'],
['000', '01', '101'],
['000', '01', '110'],
['000', '01', '111'],
['000', '10', '01'],
['000', '10', '11'],
['000', '10', '001'],
['000', '10', '010'],
['000', '10', '011'],
['000', '10', '110'],
['000', '10', '111'],
['000', '11', '01'],
['000', '11', '10'],
['000', '11', '001'],
['000', '11', '010'],
['000', '11', '011'],
['000', '11', '100'],
['000', '11', '101'],
['000', '001', '1'],
['000', '001', '01'],
['000', '001', '10'],
['000', '001', '11'],
['000', '001', '010'],
['000', '001', '011'],
['000', '001', '100'],
['000', '001', '101'],
['000', '001', '110'],
['000', '001', '111'],
['000', '010', '1'],
['000', '010', '10'],
['000', '010', '11'],
['000', '010', '001'],
['000', '010', '011'],
['000', '010', '100'],
['000', '010', '101'],
['000', '010', '110'],
['000', '010', '111'],
['000', '011', '1'],
['000', '011', '10'],
['000', '011', '11'],
['000', '011', '001'],
['000', '011', '010'],
['000', '011', '100'],
['000', '011', '101'],
['000', '011', '110'],
['000', '011', '111'],
['000', '100', '01'],
['000', '100', '11'],
['000', '100', '001'],
['000', '100', '010'],
['000', '100', '011'],
['000', '100', '101'],
['000', '100', '110'],
['000', '100', '111'],
['000', '101', '01'],
['000', '101', '11'],
['000', '101', '001'],
['000', '101', '010'],
['000', '101', '011'],
['000', '101', '100'],
['000', '101', '110'],
['000', '101', '111'],
['000', '110', '01'],
['000', '110', '10'],
['000', '110', '001'],
['000', '110', '010'],
['000', '110', '011'],
['000', '110', '100'],
['000', '110', '101'],
['000', '110', '111'],
['000', '111', '01'],
['000', '111', '10'],
['000', '111', '001'],
['000', '111', '010'],
['000', '111', '011'],
['000', '111', '100'],
['000', '111', '101'],
['000', '111', '110'],
['001', '1', '01'],
['001', '1', '000'],
['001', '1', '010'],
['001', '1', '011'],
['001', '01', '1'],
['001', '01', '10'],
['001', '01', '11'],
['001', '01', '000'],
['001', '01', '100'],
['001', '01', '101'],
['001', '01', '110'],
['001', '01', '111'],
['001', '10', '01'],
['001', '10', '11'],
['001', '10', '000'],
['001', '10', '010'],
['001', '10', '011'],
['001', '10', '110'],
['001', '10', '111'],
['001', '11', '01'],
['001', '11', '10'],
['001', '11', '000'],
['001', '11', '010'],
['001', '11', '011'],
['001', '11', '100'],
['001', '11', '101'],
['001', '000', '1'],
['001', '000', '01'],
['001', '000', '10'],
['001', '000', '11'],
['001', '000', '010'],
['001', '000', '011'],
['001', '000', '100'],
['001', '000', '101'],
['001', '000', '110'],
['001', '000', '111'],
['001', '010', '1'],
['001', '010', '10'],
['001', '010', '11'],
['001', '010', '000'],
['001', '010', '011'],
['001', '010', '100'],
['001', '010', '101'],
['001', '010', '110'],
['001', '010', '111'],
['001', '011', '1'],
['001', '011', '10'],
['001', '011', '11'],
['001', '011', '000'],
['001', '011', '010'],
['001', '011', '100'],
['001', '011', '101'],
['001', '011', '110'],
['001', '011', '111'],
['001', '100', '01'],
['001', '100', '11'],
['001', '100', '000'],
['001', '100', '010'],
['001', '100', '011'],
['001', '100', '101'],
['001', '100', '110'],
['001', '100', '111'],
['001', '101', '01'],
['001', '101', '11'],
['001', '101', '000'],
['001', '101', '010'],
['001', '101', '011'],
['001', '101', '100'],
['001', '101', '110'],
['001', '101', '111'],
['001', '110', '01'],
['001', '110', '10'],
['001', '110', '000'],
['001', '110', '010'],
['001', '110', '011'],
['001', '110', '100'],
['001', '110', '101'],
['001', '110', '111'],
['001', '111', '01'],
['001', '111', '10'],
['001', '111', '000'],
['001', '111', '010'],
['001', '111', '011'],
['001', '111', '100'],
['001', '111', '101'],
['001', '111', '110'],
['010', '1', '00'],
['010', '1', '000'],
['010', '1', '001'],
['010', '1', '011'],
['010', '00', '1'],
['010', '00', '10'],
['010', '00', '11'],
['010', '00', '011'],
['010', '00', '100'],
['010', '00', '101'],
['010', '00', '110'],
['010', '00', '111'],
['010', '10', '00'],
['010', '10', '11'],
['010', '10', '000'],
['010', '10', '001'],
['010', '10', '011'],
['010', '10', '110'],
['010', '10', '111'],
['010', '11', '00'],
['010', '11', '10'],
['010', '11', '000'],
['010', '11', '001'],
['010', '11', '011'],
['010', '11', '100'],
['010', '11', '101'],
['010', '000', '1'],
['010', '000', '10'],
['010', '000', '11'],
['010', '000', '001'],
['010', '000', '011'],
['010', '000', '100'],
['010', '000', '101'],
['010', '000', '110'],
['010', '000', '111'],
['010', '001', '1'],
['010', '001', '10'],
['010', '001', '11'],
['010', '001', '000'],
['010', '001', '011'],
['010', '001', '100'],
['010', '001', '101'],
['010', '001', '110'],
['010', '001', '111'],
['010', '011', '1'],
['010', '011', '00'],
['010', '011', '10'],
['010', '011', '11'],
['010', '011', '000'],
['010', '011', '001'],
['010', '011', '100'],
['010', '011', '101'],
['010', '011', '110'],
['010', '011', '111'],
['010', '100', '00'],
['010', '100', '11'],
['010', '100', '000'],
['010', '100', '001'],
['010', '100', '011'],
['010', '100', '101'],
['010', '100', '110'],
['010', '100', '111'],
['010', '101', '00'],
['010', '101', '11'],
['010', '101', '000'],
['010', '101', '001'],
['010', '101', '011'],
['010', '101', '100'],
['010', '101', '110'],
['010', '101', '111'],
['010', '110', '00'],
['010', '110', '10'],
['010', '110', '000'],
['010', '110', '001'],
['010', '110', '011'],
['010', '110', '100'],
['010', '110', '101'],
['010', '110', '111'],
['010', '111', '00'],
['010', '111', '10'],
['010', '111', '000'],
['010', '111', '001'],
['010', '111', '011'],
['010', '111', '100'],
['010', '111', '101'],
['010', '111', '110'],
['011', '1', '00'],
['011', '1', '000'],
['011', '1', '001'],
['011', '1', '010'],
['011', '00', '1'],
['011', '00', '10'],
['011', '00', '11'],
['011', '00', '010'],
['011', '00', '100'],
['011', '00', '101'],
['011', '00', '110'],
['011', '00', '111'],
['011', '10', '00'],
['011', '10', '11'],
['011', '10', '000'],
['011', '10', '001'],
['011', '10', '010'],
['011', '10', '110'],
['011', '10', '111'],
['011', '11', '00'],
['011', '11', '10'],
['011', '11', '000'],
['011', '11', '001'],
['011', '11', '010'],
['011', '11', '100'],
['011', '11', '101'],
['011', '000', '1'],
['011', '000', '10'],
['011', '000', '11'],
['011', '000', '001'],
['011', '000', '010'],
['011', '000', '100'],
['011', '000', '101'],
['011', '000', '110'],
['011', '000', '111'],
['011', '001', '1'],
['011', '001', '10'],
['011', '001', '11'],
['011', '001', '000'],
['011', '001', '010'],
['011', '001', '100'],
['011', '001', '101'],
['011', '001', '110'],
['011', '001', '111'],
['011', '010', '1'],
['011', '010', '00'],
['011', '010', '10'],
['011', '010', '11'],
['011', '010', '000'],
['011', '010', '001'],
['011', '010', '100'],
['011', '010', '101'],
['011', '010', '110'],
['011', '010', '111'],
['011', '100', '00'],
['011', '100', '11'],
['011', '100', '000'],
['011', '100', '001'],
['011', '100', '010'],
['011', '100', '101'],
['011', '100', '110'],
['011', '100', '111'],
['011', '101', '00'],
['011', '101', '11'],
['011', '101', '000'],
['011', '101', '001'],
['011', '101', '010'],
['011', '101', '100'],
['011', '101', '110'],
['011', '101', '111'],
['011', '110', '00'],
['011', '110', '10'],
['011', '110', '000'],
['011', '110', '001'],
['011', '110', '010'],
['011', '110', '100'],
['011', '110', '101'],
['011', '110', '111'],
['011', '111', '00'],
['011', '111', '10'],
['011', '111', '000'],
['011', '111', '001'],
['011', '111', '010'],
['011', '111', '100'],
['011', '111', '101'],
['011', '111', '110'],
['100', '0', '11'],
['100', '0', '101'],
['100', '0', '110'],
['100', '0', '111'],
['100', '00', '01'],
['100', '00', '11'],
['100', '00', '010'],
['100', '00', '011'],
['100', '00', '101'],
['100', '00', '110'],
['100', '00', '111'],
['100', '01', '00'],
['100', '01', '11'],
['100', '01', '000'],
['100', '01', '001'],
['100', '01', '101'],
['100', '01', '110'],
['100', '01', '111'],
['100', '11', '0'],
['100', '11', '00'],
['100', '11', '01'],
['100', '11', '000'],
['100', '11', '001'],
['100', '11', '010'],
['100', '11', '011'],
['100', '11', '101'],
['100', '000', '01'],
['100', '000', '11'],
['100', '000', '001'],
['100', '000', '010'],
['100', '000', '011'],
['100', '000', '101'],
['100', '000', '110'],
['100', '000', '111'],
['100', '001', '01'],
['100', '001', '11'],
['100', '001', '000'],
['100', '001', '010'],
['100', '001', '011'],
['100', '001', '101'],
['100', '001', '110'],
['100', '001', '111'],
['100', '010', '00'],
['100', '010', '11'],
['100', '010', '000'],
['100', '010', '001'],
['100', '010', '011'],
['100', '010', '101'],
['100', '010', '110'],
['100', '010', '111'],
['100', '011', '00'],
['100', '011', '11'],
['100', '011', '000'],
['100', '011', '001'],
['100', '011', '010'],
['100', '011', '101'],
['100', '011', '110'],
['100', '011', '111'],
['100', '101', '0'],
['100', '101', '00'],
['100', '101', '01'],
['100', '101', '11'],
['100', '101', '000'],
['100', '101', '001'],
['100', '101', '010'],
['100', '101', '011'],
['100', '101', '110'],
['100', '101', '111'],
['100', '110', '0'],
['100', '110', '00'],
['100', '110', '01'],
['100', '110', '000'],
['100', '110', '001'],
['100', '110', '010'],
['100', '110', '011'],
['100', '110', '101'],
['100', '110', '111'],
['100', '111', '0'],
['100', '111', '00'],
['100', '111', '01'],
['100', '111', '000'],
['100', '111', '001'],
['100', '111', '010'],
['100', '111', '011'],
['100', '111', '101'],
['100', '111', '110'],
['101', '0', '11'],
['101', '0', '100'],
['101', '0', '110'],
['101', '0', '111'],
['101', '00', '01'],
['101', '00', '11'],
['101', '00', '010'],
['101', '00', '011'],
['101', '00', '100'],
['101', '00', '110'],
['101', '00', '111'],
['101', '01', '00'],
['101', '01', '11'],
['101', '01', '000'],
['101', '01', '001'],
['101', '01', '100'],
['101', '01', '110'],
['101', '01', '111'],
['101', '11', '0'],
['101', '11', '00'],
['101', '11', '01'],
['101', '11', '000'],
['101', '11', '001'],
['101', '11', '010'],
['101', '11', '011'],
['101', '11', '100'],
['101', '000', '01'],
['101', '000', '11'],
['101', '000', '001'],
['101', '000', '010'],
['101', '000', '011'],
['101', '000', '100'],
['101', '000', '110'],
['101', '000', '111'],
['101', '001', '01'],
['101', '001', '11'],
['101', '001', '000'],
['101', '001', '010'],
['101', '001', '011'],
['101', '001', '100'],
['101', '001', '110'],
['101', '001', '111'],
['101', '010', '00'],
['101', '010', '11'],
['101', '010', '000'],
['101', '010', '001'],
['101', '010', '011'],
['101', '010', '100'],
['101', '010', '110'],
['101', '010', '111'],
['101', '011', '00'],
['101', '011', '11'],
['101', '011', '000'],
['101', '011', '001'],
['101', '011', '010'],
['101', '011', '100'],
['101', '011', '110'],
['101', '011', '111'],
['101', '100', '0'],
['101', '100', '00'],
['101', '100', '01'],
['101', '100', '11'],
['101', '100', '000'],
['101', '100', '001'],
['101', '100', '010'],
['101', '100', '011'],
['101', '100', '110'],
['101', '100', '111'],
['101', '110', '0'],
['101', '110', '00'],
['101', '110', '01'],
['101', '110', '000'],
['101', '110', '001'],
['101', '110', '010'],
['101', '110', '011'],
['101', '110', '100'],
['101', '110', '111'],
['101', '111', '0'],
['101', '111', '00'],
['101', '111', '01'],
['101', '111', '000'],
['101', '111', '001'],
['101', '111', '010'],
['101', '111', '011'],
['101', '111', '100'],
['101', '111', '110'],
['110', '0', '10'],
['110', '0', '100'],
['110', '0', '101'],
['110', '0', '111'],
['110', '00', '01'],
['110', '00', '10'],
['110', '00', '010'],
['110', '00', '011'],
['110', '00', '100'],
['110', '00', '101'],
['110', '00', '111'],
['110', '01', '00'],
['110', '01', '10'],
['110', '01', '000'],
['110', '01', '001'],
['110', '01', '100'],
['110', '01', '101'],
['110', '01', '111'],
['110', '10', '0'],
['110', '10', '00'],
['110', '10', '01'],
['110', '10', '000'],
['110', '10', '001'],
['110', '10', '010'],
['110', '10', '011'],
['110', '10', '111'],
['110', '000', '01'],
['110', '000', '10'],
['110', '000', '001'],
['110', '000', '010'],
['110', '000', '011'],
['110', '000', '100'],
['110', '000', '101'],
['110', '000', '111'],
['110', '001', '01'],
['110', '001', '10'],
['110', '001', '000'],
['110', '001', '010'],
['110', '001', '011'],
['110', '001', '100'],
['110', '001', '101'],
['110', '001', '111'],
['110', '010', '00'],
['110', '010', '10'],
['110', '010', '000'],
['110', '010', '001'],
['110', '010', '011'],
['110', '010', '100'],
['110', '010', '101'],
['110', '010', '111'],
['110', '011', '00'],
['110', '011', '10'],
['110', '011', '000'],
['110', '011', '001'],
['110', '011', '010'],
['110', '011', '100'],
['110', '011', '101'],
['110', '011', '111'],
['110', '100', '0'],
['110', '100', '00'],
['110', '100', '01'],
['110', '100', '000'],
['110', '100', '001'],
['110', '100', '010'],
['110', '100', '011'],
['110', '100', '101'],
['110', '100', '111'],
['110', '101', '0'],
['110', '101', '00'],
['110', '101', '01'],
['110', '101', '000'],
['110', '101', '001'],
['110', '101', '010'],
['110', '101', '011'],
['110', '101', '100'],
['110', '101', '111'],
['110', '111', '0'],
['110', '111', '00'],
['110', '111', '01'],
['110', '111', '10'],
['110', '111', '000'],
['110', '111', '001'],
['110', '111', '010'],
['110', '111', '011'],
['110', '111', '100'],
['110', '111', '101'],
['111', '0', '10'],
['111', '0', '100'],
['111', '0', '101'],
['111', '0', '110'],
['111', '00', '01'],
['111', '00', '10'],
['111', '00', '010'],
['111', '00', '011'],
['111', '00', '100'],
['111', '00', '101'],
['111', '00', '110'],
['111', '01', '00'],
['111', '01', '10'],
['111', '01', '000'],
['111', '01', '001'],
['111', '01', '100'],
['111', '01', '101'],
['111', '01', '110'],
['111', '10', '0'],
['111', '10', '00'],
['111', '10', '01'],
['111', '10', '000'],
['111', '10', '001'],
['111', '10', '010'],
['111', '10', '011'],
['111', '10', '110'],
['111', '000', '01'],
['111', '000', '10'],
['111', '000', '001'],
['111', '000', '010'],
['111', '000', '011'],
['111', '000', '100'],
['111', '000', '101'],
['111', '000', '110'],
['111', '001', '01'],
['111', '001', '10'],
['111', '001', '000'],
['111', '001', '010'],
['111', '001', '011'],
['111', '001', '100'],
['111', '001', '101'],
['111', '001', '110'],
['111', '010', '00'],
['111', '010', '10'],
['111', '010', '000'],
['111', '010', '001'],
['111', '010', '011'],
['111', '010', '100'],
['111', '010', '101'],
['111', '010', '110'],
['111', '011', '00'],
['111', '011', '10'],
['111', '011', '000'],
['111', '011', '001'],
['111', '011', '010'],
['111', '011', '100'],
['111', '011', '101'],
['111', '011', '110'],
['111', '100', '0'],
['111', '100', '00'],
['111', '100', '01'],
['111', '100', '000'],
['111', '100', '001'],
['111', '100', '010'],
['111', '100', '011'],
['111', '100', '101'],
['111', '100', '110'],
['111', '101', '0'],
['111', '101', '00'],
['111', '101', '01'],
['111', '101', '000'],
['111', '101', '001'],
['111', '101', '010'],
['111', '101', '011'],
['111', '101', '100'],
['111', '101', '110'],
['111', '110', '0'],
['111', '110', '00'],
['111', '110', '01'],
['111', '110', '10'],
['111', '110', '000'],
['111', '110', '001'],
['111', '110', '010'],
['111', '110', '011'],
['111', '110', '100'],
['111', '110', '101']]