Log in to get your input and submit your answers.
Day 09: Encoding Error
After repairing the iMacs' boot sequence, you finally connect to the cluster network. But something is wrong: the connection to the Intra is bogged down by a continuous stream of data broadcast by the Bocal's central server.
The transmission protocol uses a sliding-window data integrity cipher: each number transmitted must be the sum of two distinct numbers among the 25 numbers immediately preceding it.
The first 25 numbers form a synchronization preamble and are exempt from this rule.
Part 1
Suddenly, an anomaly appears in the stream! A corrupted value violates the protocol rule.
Example
Suppose a test stream with a preamble reduced to 5 numbers:
35
20
15
25
47
40
62
55
65
95
102
117
150
182
127
219
299
277
309
576In this example, following the 5-number preamble:
40is valid because15 + 25 = 40.62is valid because15 + 47 = 62.55is valid because15 + 40 = 55.65is valid because25 + 40 = 65.- And so forth, until
127... 127is invalid: no pair among the previous 5 numbers (95, 102, 117, 150, 182) sums to 127.
In this example, the first anomaly is 127.
Analyze your full input stream (with a 25-number preamble). What is the first number that is not the sum of two of the 25 numbers immediately before it?