Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def day17_part2(s):
- program = list(map(int, s.split('Program: ')[1].split(',')))
- k1, k2 = (program[i + 1] for i in range(0, len(program), 2) if program[i] == 1) # 'bst' params.
- def explore(a, values):
- if not values:
- return a
- solutions = (
- explore(a * 8 + b, values[1:])
- for b in range(8)
- if (b ^ k1 ^ k2 ^ ((a * 8 + b) >> (b ^ k1))) & 7 == values[0]
- )
- return min(solutions, default=1 << 62)
- return explore(0, program[::-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement