Advent of Code 2020: Python Solution (25 Part Series)
1 Advent of Code 2020: Python Solution Day 1
2 Advent of Code 2020: Python Solution Day 2
… 21 more parts…
3 Advent of Code 2020: Python Solution Day 3
4 Advent of Code 2020: Python Solution Day 4
5 Advent of Code 2020: Python Solution Day 5
6 Advent of Code 2020: Python Solution Day 6
7 Advent of Code 2020: Python Solution Day 7
8 Advent of Code 2020: Python Solution Day 8
9 Advent of Code 2020: Python Solution Day 9
10 Advent of Code 2020: Python Solution Day 10
11 Advent of Code 2020: Python Solution Day 11
12 Advent of Code 2020: Python Solution Day 12
13 Advent of Code 2020: Python Solution Day 13
14 Advent of Code 2020: Python Solution Day 14
15 Advent of Code 2020: Python Solution Day 15
16 Advent of Code 2020: Python Solution Day 16
17 Advent of Code 2020: Python Solution Day 17
18 Advent of Code 2020: Python Solution Day 18
19 Advent of Code 2020: Python Solution Day 19
20 Advent of Code 2020: Python Solution Day 20
21 Advent of Code 2020: Python Solution Day 21
22 Advent of Code 2020: Python Solution Day 22
23 Advent of Code 2020: Python Solution Day 23
24 Advent of Code 2020: Python Solution Day 24
25 Advent of Code 2020: Python Solution Day 25
This is my first ever challenge and I was amazed by the challenges. I am proficient in Python so all codes will be on Python3.
Day 1 seems to be easier to tackle.
I am saving my input as day1.txt
on same directory as my Jupyter Notebook is.
with open("day1.txt", "r") as fp:
num = fp.readlines()
# print(num) num = [int(i.split("\n")[0]) for i in num]
print("Solution: 1\n")
# solution 1 for i in num:
if 2020-i in num:
print(i, 2020-i, i*(2020-i))
print("Solution: 2\n")
# solution 2 for i in num:
for j in num:
if (2020-i - j) in num:
print(2020-i-j, i, j)
Enter fullscreen mode Exit fullscreen mode
Result of above code is given below:
Solution: 1
933 1087 1014171
1087 933 1014171
Solution: 2
566 59 1395
1395 59 566
566 1395 59
59 1395 566
1395 566 59
59 566 1395
Enter fullscreen mode Exit fullscreen mode
I write blogs about Computer Vision projects on my GitHub page q-viper.github.io and if you got some time please share yours too.
Advent of Code 2020: Python Solution (25 Part Series)
1 Advent of Code 2020: Python Solution Day 1
2 Advent of Code 2020: Python Solution Day 2
… 21 more parts…
3 Advent of Code 2020: Python Solution Day 3
4 Advent of Code 2020: Python Solution Day 4
5 Advent of Code 2020: Python Solution Day 5
6 Advent of Code 2020: Python Solution Day 6
7 Advent of Code 2020: Python Solution Day 7
8 Advent of Code 2020: Python Solution Day 8
9 Advent of Code 2020: Python Solution Day 9
10 Advent of Code 2020: Python Solution Day 10
11 Advent of Code 2020: Python Solution Day 11
12 Advent of Code 2020: Python Solution Day 12
13 Advent of Code 2020: Python Solution Day 13
14 Advent of Code 2020: Python Solution Day 14
15 Advent of Code 2020: Python Solution Day 15
16 Advent of Code 2020: Python Solution Day 16
17 Advent of Code 2020: Python Solution Day 17
18 Advent of Code 2020: Python Solution Day 18
19 Advent of Code 2020: Python Solution Day 19
20 Advent of Code 2020: Python Solution Day 20
21 Advent of Code 2020: Python Solution Day 21
22 Advent of Code 2020: Python Solution Day 22
23 Advent of Code 2020: Python Solution Day 23
24 Advent of Code 2020: Python Solution Day 24
25 Advent of Code 2020: Python Solution Day 25
暂无评论内容