Created
December 6, 2017 20:56
-
-
Save pta2002/58b644f0d60924d0e0e00f1903f26b10 to your computer and use it in GitHub Desktop.
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
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