Skip to content

Instantly share code, notes, and snippets.

@pta2002
Created December 6, 2017 20:56
Show Gist options
  • Save pta2002/58b644f0d60924d0e0e00f1903f26b10 to your computer and use it in GitHub Desktop.
Save pta2002/58b644f0d60924d0e0e00f1903f26b10 to your computer and use it in GitHub Desktop.
def parse(s):
n = []
for l in s.split('\n'):
if l != '':
n.append(int(l))
return n
with open('d5in.txt') as f:
nums = parse(f.read())
pos = 0
c = 0
while pos < len(nums) and pos >= 0:
n = nums[pos]
if n >= 3:
nums[pos] -= 1
else:
nums[pos] += 1
pos += n
c += 1
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment