Added 2020 (python)

This commit is contained in:
Karma Riuk
2023-08-02 11:39:56 +02:00
commit 410815acf8
93 changed files with 11719 additions and 0 deletions

Binary file not shown.

93
2020/10/input Normal file
View File

@ -0,0 +1,93 @@
47
99
115
65
10
55
19
73
80
100
71
110
64
135
49
3
1
98
132
2
38
118
66
116
104
87
79
114
40
37
44
97
4
140
60
86
56
133
7
146
85
111
134
53
121
77
117
21
12
81
145
129
107
93
22
48
11
54
92
78
67
20
138
125
57
96
26
147
124
34
74
143
13
28
126
50
29
70
39
63
41
91
32
84
144
27
139
33
88
72
23
103
16

23
2020/10/prog.py Normal file
View File

@ -0,0 +1,23 @@
def get_input(sample = False, number = 1):
with open(f"sample_{number}" if sample else "input", 'r') as f:
return [int(i) for i in f.readlines()]
def get_result(data: list, part = 1):
data.sort()
data = [0] + data + [data[-1] + 3]
diffs = []
for i in range(len(data) - 1):
n1, n2 = data[i], data[i + 1]
diffs.append(n2 - n1)
if part == 1:
return diffs.count(1) * diffs.count(3)
else:
for diff in diffs
return 0
if __name__ == "__main__":
print(get_result(get_input()))

11
2020/10/sample_1 Normal file
View File

@ -0,0 +1,11 @@
16
10
15
5
1
11
7
19
6
12
4

31
2020/10/sample_2 Normal file
View File

@ -0,0 +1,31 @@
28
33
18
42
31
14
46
20
48
47
24
23
49
45
19
38
39
11
1
32
25
35
8
17
7
9
4
2
34
10
3

12
2020/10/test.py Normal file
View File

@ -0,0 +1,12 @@
from prog import *
inp_1 = get_input(sample = True, number = 1)
result_1_1 = get_result(inp_1)
expected_1_1 = 35
print(f"{result_1_1 = } {result_1_1 == expected_1_1}")
inp_2 = get_input(sample = True, number = 2)
result_1_2 = get_result(inp_2)
expected_1_2 = 220
print(f"{result_1_2 = } {result_1_2 == expected_1_2}")