You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
816 B
42 lines
816 B
#!/usr/bin/env python
|
|
|
|
|
|
def getNums(nums):
|
|
numsLen = len(nums)
|
|
|
|
for i in range(numsLen):
|
|
for j in range(numsLen):
|
|
if( nums[i] + nums[j] == 2020 ):
|
|
return nums[i], nums[j]
|
|
|
|
print("None found :(")
|
|
return
|
|
|
|
|
|
def getNumsPart2(nums):
|
|
numsLen = len(nums)
|
|
for i in range(numsLen):
|
|
for j in range(numsLen):
|
|
for k in range(numsLen):
|
|
if( nums[i] + nums[j] + nums[k] == 2020 ):
|
|
return nums[i], nums[j], nums[k]
|
|
|
|
print("None found")
|
|
|
|
inp = open("input", "r")
|
|
nums = inp.read().splitlines()
|
|
|
|
nums = list(map(int, nums))
|
|
print(nums)
|
|
|
|
|
|
# PART 1
|
|
x, y = getNums(nums)
|
|
theNum = x * y
|
|
print( f"1; OUTPUT: {getNums(nums)} | theNum: {theNum}" )
|
|
|
|
|
|
# PART 2
|
|
x, y, z = getNumsPart2(nums)
|
|
theNum = x * y * z
|
|
print(theNum)
|
|
|