Fixed 24th and 36th tasks, fixed names for 71th and 41th

This commit is contained in:
Dmitriy Shishkov 2021-02-18 20:44:14 +05:00
parent 1590534203
commit 422ee86263
No known key found for this signature in database
GPG Key ID: 7CAE12ED13853CAC
13 changed files with 1380 additions and 48 deletions

5
18/24.csv Normal file
View File

@ -0,0 +1,5 @@
10 ;20 ;10 ;30 ;40
101;101;30 ;15 ;50
5 ;7 ;8 ;200;1
6 ;-10;10 ;200;80
-30;-10;11 ;12 ;1
1 10 20 10 30 40
2 101 101 30 15 50
3 5 7 8 200 1
4 6 -10 10 200 80
5 -30 -10 11 12 1

View File

@ -11,19 +11,31 @@ def count(a: list[list[int]], i: int, j: int) -> list[int]:
c = a[i][j]
if r == None and b == None and i == len(a)-1 and j == len(a[0])-1:
return [[c, [[i, j]]], [c, [[i, j]]]]
if r == None and b == None:
return [c, c]
return None
if r == None:
return [c + b[0], c + b[1]]
return [[c + b[0][0], [*b[0][1], [i, j]]], [c + b[1][0], [*b[1][1], [i, j]]]]
if b == None:
return [c + r[0], c + r[1]]
return [[c + r[0][0], [*r[0][1], [i, j]]], [c + r[1][0], [*r[1][1], [i, j]]]]
return [c + max(r[0], b[0]), c + min(r[1], b[1])]
mmax = max(r[0][0], b[0][0])
mmin = min(r[1][0], b[1][0])
Marr = r[0][1] if mmax == r[0][0] else b[0][1]
marr = r[1][1] if mmin == r[1][0] else b[1][1]
return [[c + mmax, [*Marr, [i, j]]], [c + mmin, [*marr, [i, j]]]]
with open("dat/18-13.csv", 'r') as f:
a = [[int(i) for i in row.split(';')] for row in f.readlines()]
# with open("24.csv", 'r') as f:
a = [[int(i.strip()) for i in row.split(';')] for row in f.readlines()]
print(count(a, 0, 0))
ret = count(a, 0, 0)
# 1535 330 (не знаю как починить с минимумом)
print(ret[0])
print(ret[1])
# 1535 975

View File

@ -1,36 +0,0 @@
#include <iostream>
#include <fstream>
using namespace std;
// 345 (Даже написал на плюсах, не знаю, что с ней не так)
int main()
{
ifstream inp("dat/18-17.txt");
double p = INT8_MAX;
double msum = INT8_MIN;
double sum = 0;
while (!inp.eof())
{
double n;
inp >> n;
if (n < p)
{
sum += n;
if (sum > msum)
msum = sum;
}
else
sum = 0;
p = n;
}
cout << (int)msum << endl;
return 0;
}

View File

@ -1,4 +1,4 @@
# 345 (Даже написал на плюсах, не знаю, что с ней не так)
# 495 (я дурашка)
with open('./dat/18-17.txt', 'r') as f:
p = float('+inf')
@ -12,7 +12,7 @@ with open('./dat/18-17.txt', 'r') as f:
if s > ms:
ms = s
else:
s = 0
s = n
p = n
print(ms)
print(int(ms))

View File

View File

@ -10,8 +10,10 @@ def count(a, i, j):
c = a[i][j] if a[i][j] % 3 == 0 or a[i][j] % 4 == 0 else 0
if l == None and t == None:
if l == None and t == None and i == 0 and j == 0:
return [c, c]
if l == None and t == None:
return None
if l == None:
return [c + t[0], c + t[1]]
if t == None:
@ -24,4 +26,4 @@ a = [[int(i) for i in row.split(';')] for row in open('dat/18-11.csv', 'r')]
print(count(a, len(a)-1, len(a[0])-1))
# 1021 222
# 1021 222

12
18/dat/18-11.csv Normal file
View File

@ -0,0 +1,12 @@
24;13;11;50;77;69;74;10;5;98;37;49
81;85;55;97;56;93;160;46;45;31;28;51
26;97;64;98;59;42;133;74;39;56;12;86
11;83;18;93;64;48;5;97;6;14;58;78
86;81;432;39;4;2;67;11;16;87;81;46
81;17;28;24;18;89;1;10;42;58;39;7
74;43;333;10;57;31;90;37;25;499;26;93
142;56;45;57;37;13;4;9;34;62;87;94
66;20;84;88;34;64;95;45;1;14;51;8
37;14;22;16;9;60;38;38;48;24;42;82
83;84;98;85;499;48;56;55;90;99;7;3
23;64;76;32;65;15;81;57;83;48;61;68
1 24 13 11 50 77 69 74 10 5 98 37 49
2 81 85 55 97 56 93 160 46 45 31 28 51
3 26 97 64 98 59 42 133 74 39 56 12 86
4 11 83 18 93 64 48 5 97 6 14 58 78
5 86 81 432 39 4 2 67 11 16 87 81 46
6 81 17 28 24 18 89 1 10 42 58 39 7
7 74 43 333 10 57 31 90 37 25 499 26 93
8 142 56 45 57 37 13 4 9 34 62 87 94
9 66 20 84 88 34 64 95 45 1 14 51 8
10 37 14 22 16 9 60 38 38 48 24 42 82
11 83 84 98 85 499 48 56 55 90 99 7 3
12 23 64 76 32 65 15 81 57 83 48 61 68

12
18/dat/18-13.csv Normal file
View File

@ -0,0 +1,12 @@
58;85;-5;36;7;48;27;100;30;31;94;16
47;13;32;46;100;34;144;31;74;96;25;92
46;83;144;74;34;346;65;10;-10;20;40;52
44;37;39;73;69;78;57;33;-16;40;82;19
85;70;6;42;81;3;52;87;345;74;22;30
96;23;91;77;333;20;72;120;15;86;48;57
17;37;-100;50;87;47;94;62;45;26;34;58
63;40;6;53;-22;12;94;53;54;42;1;25
40;43;24;61;90;91;90;3;99;74;57;91
90;72;123;92;19;58;72;56;28;43;62;59
85;62;99;111;51;-91;72;13;54;47;64;94
5;12;2;89;33;61;26;64;53;43;109;15
1 58 85 -5 36 7 48 27 100 30 31 94 16
2 47 13 32 46 100 34 144 31 74 96 25 92
3 46 83 144 74 34 346 65 10 -10 20 40 52
4 44 37 39 73 69 78 57 33 -16 40 82 19
5 85 70 6 42 81 3 52 87 345 74 22 30
6 96 23 91 77 333 20 72 120 15 86 48 57
7 17 37 -100 50 87 47 94 62 45 26 34 58
8 63 40 6 53 -22 12 94 53 54 42 1 25
9 40 43 24 61 90 91 90 3 99 74 57 91
10 90 72 123 92 19 58 72 56 28 43 62 59
11 85 62 99 111 51 -91 72 13 54 47 64 94
12 5 12 2 89 33 61 26 64 53 43 109 15

BIN
18/dat/18-13s.ods Normal file

Binary file not shown.

10
18/dat/18-2.csv Normal file
View File

@ -0,0 +1,10 @@
15;43;23;44;85;19;72;67;36;80
100;48;92;64;91;61;71;2;82;74
69;9;12;9;91;52;94;58;69;42
53;42;18;58;93;55;48;76;18;13
49;63;16;13;45;6;81;19;53;63
49;53;23;44;61;2;2;63;88;16
2;75;100;27;72;64;95;49;51;84
64;68;17;16;18;2;30;57;86;6
64;84;53;19;23;91;82;2;2;59
72;47;56;85;9;26;47;48;91;91
1 15 43 23 44 85 19 72 67 36 80
2 100 48 92 64 91 61 71 2 82 74
3 69 9 12 9 91 52 94 58 69 42
4 53 42 18 58 93 55 48 76 18 13
5 49 63 16 13 45 6 81 19 53 63
6 49 53 23 44 61 2 2 63 88 16
7 2 75 100 27 72 64 95 49 51 84
8 64 68 17 16 18 2 30 57 86 6
9 64 84 53 19 23 91 82 2 2 59
10 72 47 56 85 9 26 47 48 91 91

300
18/dat/18-k1.csv Normal file
View File

@ -0,0 +1,300 @@
41
104
59
45
156
79
120
137
133
121
186
155
110
162
126
29
21
71
12
66
52
86
101
182
181
168
14
150
72
187
69
20
150
11
39
119
174
120
65
160
17
139
54
72
185
102
181
25
142
65
164
84
160
178
30
100
166
11
57
197
110
95
55
101
38
145
69
88
29
184
135
115
160
86
166
11
39
89
84
200
77
30
135
140
164
54
32
94
100
32
94
168
199
188
104
181
187
77
186
75
46
82
134
67
180
57
27
170
12
158
140
59
75
25
195
108
88
40
173
171
194
31
92
21
67
79
71
80
172
119
147
164
46
10
47
150
160
14
40
116
195
103
39
150
129
100
189
199
124
50
177
34
69
184
141
99
10
51
82
18
60
67
132
129
184
195
91
88
165
125
128
178
119
95
129
171
107
164
38
136
190
154
98
29
180
46
102
159
12
183
167
47
13
40
97
114
126
87
64
147
60
36
121
132
56
146
146
95
196
142
100
63
138
12
129
31
32
45
148
119
196
197
162
21
139
180
49
35
150
146
102
34
200
73
94
129
96
143
86
17
14
156
97
116
175
113
117
196
10
139
93
132
133
134
155
88
186
185
177
94
170
97
165
99
116
96
114
109
27
112
84
114
97
182
124
35
90
144
71
155
177
192
39
47
153
20
86
28
80
147
48
30
58
26
14
175
116
29
85
168
1 41
2 104
3 59
4 45
5 156
6 79
7 120
8 137
9 133
10 121
11 186
12 155
13 110
14 162
15 126
16 29
17 21
18 71
19 12
20 66
21 52
22 86
23 101
24 182
25 181
26 168
27 14
28 150
29 72
30 187
31 69
32 20
33 150
34 11
35 39
36 119
37 174
38 120
39 65
40 160
41 17
42 139
43 54
44 72
45 185
46 102
47 181
48 25
49 142
50 65
51 164
52 84
53 160
54 178
55 30
56 100
57 166
58 11
59 57
60 197
61 110
62 95
63 55
64 101
65 38
66 145
67 69
68 88
69 29
70 184
71 135
72 115
73 160
74 86
75 166
76 11
77 39
78 89
79 84
80 200
81 77
82 30
83 135
84 140
85 164
86 54
87 32
88 94
89 100
90 32
91 94
92 168
93 199
94 188
95 104
96 181
97 187
98 77
99 186
100 75
101 46
102 82
103 134
104 67
105 180
106 57
107 27
108 170
109 12
110 158
111 140
112 59
113 75
114 25
115 195
116 108
117 88
118 40
119 173
120 171
121 194
122 31
123 92
124 21
125 67
126 79
127 71
128 80
129 172
130 119
131 147
132 164
133 46
134 10
135 47
136 150
137 160
138 14
139 40
140 116
141 195
142 103
143 39
144 150
145 129
146 100
147 189
148 199
149 124
150 50
151 177
152 34
153 69
154 184
155 141
156 99
157 10
158 51
159 82
160 18
161 60
162 67
163 132
164 129
165 184
166 195
167 91
168 88
169 165
170 125
171 128
172 178
173 119
174 95
175 129
176 171
177 107
178 164
179 38
180 136
181 190
182 154
183 98
184 29
185 180
186 46
187 102
188 159
189 12
190 183
191 167
192 47
193 13
194 40
195 97
196 114
197 126
198 87
199 64
200 147
201 60
202 36
203 121
204 132
205 56
206 146
207 146
208 95
209 196
210 142
211 100
212 63
213 138
214 12
215 129
216 31
217 32
218 45
219 148
220 119
221 196
222 197
223 162
224 21
225 139
226 180
227 49
228 35
229 150
230 146
231 102
232 34
233 200
234 73
235 94
236 129
237 96
238 143
239 86
240 17
241 14
242 156
243 97
244 116
245 175
246 113
247 117
248 196
249 10
250 139
251 93
252 132
253 133
254 134
255 155
256 88
257 186
258 185
259 177
260 94
261 170
262 97
263 165
264 99
265 116
266 96
267 114
268 109
269 27
270 112
271 84
272 114
273 97
274 182
275 124
276 35
277 90
278 144
279 71
280 155
281 177
282 192
283 39
284 47
285 153
286 20
287 86
288 28
289 80
290 147
291 48
292 30
293 58
294 26
295 14
296 175
297 116
298 29
299 85
300 168

15
18/dat/18-k2.csv Normal file
View File

@ -0,0 +1,15 @@
42 100 3 87 2 6 98 19 1 48 59 99 91 33 96
15 32 6 94 38 32 74 16 85 7 14 31 4 35 93
84 25 59 24 90 25 96 52 8 21 25 3 58 72 6
43 38 54 81 37 35 24 98 94 14 62 86 75 47 57
6 62 69 56 84 50 89 99 8 18 47 57 38 100 63
55 36 34 12 93 77 45 44 84 56 8 25 29 57 60
84 35 31 66 21 94 80 52 8 62 55 21 48 69 76
10 77 83 82 35 5 24 12 35 35 72 57 34 49 88
3 16 96 78 51 92 91 67 79 81 97 26 83 73 37
36 95 25 46 91 84 33 82 98 53 8 70 52 39 63
6 59 11 11 6 13 83 20 39 65 53 68 4 55 34
27 60 15 42 15 24 12 57 20 9 1 79 29 46 60
47 52 94 76 42 38 8 24 31 8 61 24 89 52 16
92 21 56 57 61 68 41 29 11 62 2 38 27 97 56
77 32 95 53 4 95 72 28 69 7 41 89 39 67 12
1 42 100 3 87 2 6 98 19 1 48 59 99 91 33 96
2 15 32 6 94 38 32 74 16 85 7 14 31 4 35 93
3 84 25 59 24 90 25 96 52 8 21 25 3 58 72 6
4 43 38 54 81 37 35 24 98 94 14 62 86 75 47 57
5 6 62 69 56 84 50 89 99 8 18 47 57 38 100 63
6 55 36 34 12 93 77 45 44 84 56 8 25 29 57 60
7 84 35 31 66 21 94 80 52 8 62 55 21 48 69 76
8 10 77 83 82 35 5 24 12 35 35 72 57 34 49 88
9 3 16 96 78 51 92 91 67 79 81 97 26 83 73 37
10 36 95 25 46 91 84 33 82 98 53 8 70 52 39 63
11 6 59 11 11 6 13 83 20 39 65 53 68 4 55 34
12 27 60 15 42 15 24 12 57 20 9 1 79 29 46 60
13 47 52 94 76 42 38 8 24 31 8 61 24 89 52 16
14 92 21 56 57 61 68 41 29 11 62 2 38 27 97 56
15 77 32 95 53 4 95 72 28 69 7 41 89 39 67 12

1000
18/dat/18-k3.csv Normal file

File diff suppressed because it is too large Load Diff