Skip to content

Instantly share code, notes, and snippets.

@bluepichu
Last active December 13, 2019 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluepichu/3f56b2f4f756db0c85a0d32cd9443434 to your computer and use it in GitHub Desktop.
Save bluepichu/3f56b2f4f756db0c85a0d32cd9443434 to your computer and use it in GitHub Desktop.
Advent of Code 2019 day 13 partial solution
# 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