My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update day23.py

+3 -3
+3 -3
2016/day23.py
··· 23 23 cmd, x, y = program[pc] 24 24 25 25 if cmd == 'cpy': 26 - # Subroutines that look like this perform multiplication: 26 + # The following instructions simply perform multiplication: 27 27 # cpy b c 28 28 # inc a 29 29 # dec c 30 30 # jnz c -2 31 31 # dec d 32 32 # jnz d -5 33 - # Perform a lookahead and optimize it by doing the following: 33 + # Perform a peephole optimization by doing the following: 34 34 # - Set a to b*d 35 35 # - Set c and d to 0. 36 - # - Move forward 5 instructions. 36 + # - Advance the PC by 5 instructions. 37 37 next_cmds, next_regs = zip(*program[pc+1:pc+5])[0:2] 38 38 39 39 if x.isalpha() and next_cmds == ('inc', 'dec', 'jnz', 'dec'):