Now that you have the structure of your transmission decoded, you can calculate the value of the expression it represents.

Literal values (type ID 4) represent a single number as described above. The remaining type IDs are more interesting:

Using these rules, you can now work out the value of the outermost packet in your BITS transmission.

For example:

Assignment

What do you get if you evaluate the expression represented by your hexadecimal-encoded BITS transmission? Determine this in the following way:

Example

In this interactive session we assume the text files transmission01.txt1, transmission02.txt2, transmission03.txt3, transmission04.txt4 and transmission05.txt5 to be located in the current directory.

>>> decode('transmission01.txt')
15
>>> decode('transmission02.txt')
46
>>> decode('transmission03.txt')
46
>>> decode('transmission04.txt')
54
>>> decode('transmission05.txt')
10637009915279