Last active
December 13, 2019 05:28
-
-
Save bluepichu/3f56b2f4f756db0c85a0d32cd9443434 to your computer and use it in GitHub Desktop.
Advent of Code 2019 day 13 partial solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# partial solution (intcode stuff cut out, but it should hopefully be clear what everything does) | |
# proc = (intcode program instance constructed from input) | |
mp = dict() | |
EMPTY = 0 | |
WALL = 1 | |
BLOCK = 2 | |
PADDLE = 3 | |
BALL = 4 | |
ball_x = 0 | |
paddle_x = 0 | |
while proc[0] != DONE: | |
if proc[0] == OUTPUT: | |
x = get_output(proc) | |
proc = cont(proc) | |
y = get_output(proc) | |
proc = cont(proc) | |
z = get_output(proc) | |
proc = cont(proc) | |
mp[(x, y)] = z | |
if z == BALL: | |
ball_x = x | |
if z == PADDLE: | |
paddle_x = x | |
else: | |
if ball_x > paddle_x: | |
proc = inpt(proc, 1) | |
elif ball_x < paddle_x: | |
proc = inpt(proc, -1) | |
else: | |
proc = inpt(proc, 0) | |
print(mp[(-1, 0)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment