Skip to content

Instantly share code, notes, and snippets.

@Ape
Created December 3, 2016 16:56
Show Gist options
  • Save Ape/2e2888feda2cfca0c99777cbf84a59c0 to your computer and use it in GitHub Desktop.
Save Ape/2e2888feda2cfca0c99777cbf84a59c0 to your computer and use it in GitHub Desktop.
AoC 2016 Day 1 Part 1 with Python
#!/usr/bin/env python3
import sys
steps = next(sys.stdin).split(", ")
x = 0
y = 0
for step in steps:
if step[0] == "R":
x, y = -y, x
else:
x, y = y, -x
x += int(step[1:])
print(abs(x) + abs(y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment