day 1
aoc 2020 » Devlog
1a.py
# find the two entries that sum to 2020 and then multiply those two numbers together # input with open('1.txt', 'r') as file: input = file.read() # turn the input into a list list_str = list(input.split('\n')) # get a list of ints list_int = [] for k in list_str: list_int.append(int(k)) # find the pair and multiply them for i in list_int: for j in list_int: if i + j == 2020: print(i*j)
1b.py
# find the three entries that sum to 2020 and then multiply those three numbers together # input with open('1.txt', 'r') as file: input = file.read() # turn the input into a list list_str = list(input.split('\n')) # get a list of ints list_int = [] for k in list_str: list_int.append(int(k)) # find the pair and multiply them for i in list_int: for j in list_int: for k in list_int: if i + j + k == 2020: print(i*j*k)
this prints the correct answer multiple times since i haven't forced i,j,k to be distinct, but i don't really care seeing as i got the correct answer lol
Files
1.txt 1.1 kB
Dec 04, 2020
1a.py 442 bytes
Dec 04, 2020
1b.py 488 bytes
Dec 04, 2020
Get aoc 2020
aoc 2020
not a mod, just some code
Status | Released |
Category | Other |
Author | riv |
Tags | advent-of-code, advent-of-code-2020, python |
Leave a comment
Log in with itch.io to leave a comment.