Skip to content

Instantly share code, notes, and snippets.

@loudambiance
Created December 16, 2021 04:14
Show Gist options
  • Save loudambiance/fdc7da133628e51008b88da5b88a907a to your computer and use it in GitHub Desktop.
Save loudambiance/fdc7da133628e51008b88da5b88a907a to your computer and use it in GitHub Desktop.
with open('task2a.txt') as f:
lines = f.read().splitlines()
x = 0
y = 0
for line in lines:
tmp = line.split(" ")
if tmp[0] == 'forward':
x = x + int(tmp[1])
elif tmp[0] == 'up':
y = y - int(tmp[1])
elif tmp[0] == 'down':
y = y + int(tmp[1])
print (x*y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment