Created
December 3, 2016 16:56
-
-
Save Ape/2e2888feda2cfca0c99777cbf84a59c0 to your computer and use it in GitHub Desktop.
AoC 2016 Day 1 Part 1 with Python
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
#!/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