-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday1.py
More file actions
28 lines (25 loc) · 725 Bytes
/
Copy pathday1.py
File metadata and controls
28 lines (25 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from sys import argv
import sys
def main():
if len(argv) != 2:
print("Usage: python program input.txt")
sys.exit(1)
elif ".txt" not in argv[1]:
print("Input must be a txt file")
sys.exit(1)
with open(argv[1]) as f:
inputs = f.readlines()
input = [int(x) for x in inputs]
a = 0
b = 0
for x in input:
num2 = 2020 - x
if num2 in input and a == 0:
a = x * num2
print(f'Answer a is: {a}')
for y in input:
num1 = num2 - y
if (b == 0 and num1 in input):
b = x * y * num1
print(f'Answer b is: {b}')
main()