More cleanup

master
E. Almqvist 4 years ago
parent 4890aa4c3c
commit 79a66e8e4b
  1. 11
      2020/9.py

@ -5,7 +5,6 @@ import re # regex
nums = list(map(int, get_input(9).splitlines())) nums = list(map(int, get_input(9).splitlines()))
def checkValid(nums, numsum): def checkValid(nums, numsum):
for num1 in nums: for num1 in nums:
for num2 in nums: for num2 in nums:
@ -22,8 +21,7 @@ def checkIfNumValid( amble, index ):
return sumnumbers, numsum2 return sumnumbers, numsum2
amble = 25 # NOTE: CHANGE ME TO 25 amble, invalid, invalidindex = 25, None, None
invalid, invalidindex = None, None
for i in range(len(nums)): for i in range(len(nums)):
if(i > amble-1): if(i > amble-1):
@ -32,8 +30,7 @@ for i in range(len(nums)):
invalid, invalidindex = valid[1], i invalid, invalidindex = valid[1], i
break break
stop = False stop, foundnums = False, []
foundnums = []
for i in range(len(nums)): for i in range(len(nums)):
for rangei in range(len(nums)): for rangei in range(len(nums)):
numlist = nums[i-rangei:i] numlist = nums[i-rangei:i]
@ -47,9 +44,7 @@ for i in range(len(nums)):
if(stop): if(stop):
break break
minnum = min(foundnums) minnum, maxnum = min(foundnums), max(foundnums)
maxnum = max(foundnums)
print("Part1:", invalid) print("Part1:", invalid)
print("Part2:", minnum + maxnum) print("Part2:", minnum + maxnum)

Loading…
Cancel
Save