Day 9: Encoding Error¶
Functions:
|
Parse the data of the XMAS protocol, |
- solve(puzzle_input: List[int], preamble_length: int) Optional[Tuple[int, int]] [source]¶
Parse the data of the XMAS protocol,
puzzle_input
, and find a weakness.- Returns
offset of the number, first number after the preamble which uncovers the weakness
- Requires
all(number >= 0 for number in puzzle_input)
len(puzzle_input) > preamble_length
- Ensures
not result or result[1] not in [ sum(t) for t in combinations(puzzle_input[result[0] - preamble_length : result[0]], 2) ]
result
⇒result[1] in puzzle_input