Context:
You are a cryptographer. You have stumbled upon a mysterious group of individuals, who present you with a challenge, which you must solve in order to join their secret society.
Description:
You have been given a binary stream consisting of 3 byte sequences that have a random width (unchanging per-stream). This stream has the following properties:
The first two bytes in a sequence are randomly generated unsigned binary numbers.
The third byte is the sum of the first two bytes.
If the sum overflows, the carry-bit disappears (That is, it does not affect the first 2 bytes).
The bytes are big-endian.
The byte-width will always be between 3 and 16.
Examples of potential streams:
A stream is an infinite series of 3 byte sequences, where the first 2 bytes are randomly generated for each sequence in the series.
Byte-width = 5: 01001 01010 10011 10010 11101 01111 ... is a valid stream (without spaces, of course). 01001 + 01010 = 10011, and 10010 + 11101 = 01111 (after integer overflow).
Byte-width = 10: 1100110011 0101010101 0010001000 ... is a valid stream. 1100110011 + 0101010101 = 0010001000 (after overflow).
The Rules:
Write a program that consumes the binary stream, and outputs (with 100% certainty) the byte-width. This puzzle has two parts, efficiency and code-golf.
Efficiency: Your score in this section is determined by the average number of bits your program must consume to make it's determination (after N>=1000 runs).
Golf: Your score in this section is determined by the number of characters used in your code. This number does not include the scaffolding to generate the stream, includes/imports, or boilerplate. For example, in C/C++: int main(){ ONLY_THIS_COUNTS }.
Your final score is equal to the multiplication of your scores in both sections. The lowest score wins.
110. Can the program terminate and return bit width 1? If not, what is the maximum base, so the program can actually terminate? \$\endgroup\$