diff --git a/18/24.csv b/18/24.csv new file mode 100644 index 0000000..b79f0eb --- /dev/null +++ b/18/24.csv @@ -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 \ No newline at end of file diff --git a/18/24.py b/18/24.py index 5c66e58..f2dd747 100644 --- a/18/24.py +++ b/18/24.py @@ -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 diff --git a/18/36.cpp b/18/36.cpp deleted file mode 100644 index ff3b70b..0000000 --- a/18/36.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -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; -} \ No newline at end of file diff --git a/18/36.py b/18/36.py index 32cd2ef..c26fbe1 100644 --- a/18/36.py +++ b/18/36.py @@ -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)) diff --git a/18/42.py b/18/41.py similarity index 100% rename from 18/42.py rename to 18/41.py diff --git a/18/72.py b/18/71.py similarity index 87% rename from 18/72.py rename to 18/71.py index 6f3388f..750b119 100644 --- a/18/72.py +++ b/18/71.py @@ -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 \ No newline at end of file +# 1021 222 diff --git a/18/dat/18-11.csv b/18/dat/18-11.csv new file mode 100644 index 0000000..2b2137d --- /dev/null +++ b/18/dat/18-11.csv @@ -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 diff --git a/18/dat/18-13.csv b/18/dat/18-13.csv new file mode 100644 index 0000000..ceff5f9 --- /dev/null +++ b/18/dat/18-13.csv @@ -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 diff --git a/18/dat/18-13s.ods b/18/dat/18-13s.ods new file mode 100644 index 0000000..5fdb2cf Binary files /dev/null and b/18/dat/18-13s.ods differ diff --git a/18/dat/18-2.csv b/18/dat/18-2.csv new file mode 100644 index 0000000..4fb67ae --- /dev/null +++ b/18/dat/18-2.csv @@ -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 diff --git a/18/dat/18-k1.csv b/18/dat/18-k1.csv new file mode 100644 index 0000000..2bdcbf1 --- /dev/null +++ b/18/dat/18-k1.csv @@ -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 diff --git a/18/dat/18-k2.csv b/18/dat/18-k2.csv new file mode 100644 index 0000000..aeb8b34 --- /dev/null +++ b/18/dat/18-k2.csv @@ -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 diff --git a/18/dat/18-k3.csv b/18/dat/18-k3.csv new file mode 100644 index 0000000..f1f800d --- /dev/null +++ b/18/dat/18-k3.csv @@ -0,0 +1,1000 @@ +123 +985 +73 +254 +438 +856 +424 +925 +182 +421 +101 +693 +233 +137 +810 +991 +209 +906 +207 +318 +220 +533 +104 +887 +480 +789 +780 +902 +459 +332 +823 +75 +576 +334 +753 +497 +759 +456 +350 +29 +873 +997 +922 +751 +827 +932 +704 +806 +319 +626 +310 +649 +138 +832 +828 +745 +453 +539 +965 +644 +878 +745 +820 +291 +665 +313 +295 +911 +474 +953 +394 +270 +750 +499 +205 +627 +995 +261 +503 +962 +237 +806 +749 +838 +209 +34 +997 +448 +505 +330 +399 +898 +546 +396 +1000 +986 +82 +185 +433 +838 +490 +665 +250 +896 +234 +832 +111 +989 +753 +353 +343 +378 +456 +494 +896 +244 +938 +665 +643 +38 +181 +644 +865 +38 +253 +584 +310 +941 +53 +163 +480 +510 +764 +954 +456 +875 +11 +669 +14 +731 +117 +622 +989 +492 +372 +546 +349 +616 +818 +605 +470 +734 +930 +697 +365 +618 +302 +931 +353 +504 +123 +789 +641 +263 +488 +856 +639 +82 +532 +562 +255 +838 +448 +560 +56 +43 +979 +63 +214 +644 +469 +945 +697 +1000 +616 +745 +814 +149 +949 +461 +841 +873 +527 +954 +376 +28 +90 +423 +780 +314 +170 +904 +805 +639 +846 +219 +555 +608 +538 +250 +660 +868 +396 +534 +339 +717 +280 +219 +470 +653 +497 +478 +927 +706 +386 +887 +996 +738 +955 +573 +605 +737 +693 +655 +28 +567 +268 +159 +436 +908 +259 +868 +782 +329 +39 +565 +494 +163 +373 +638 +218 +738 +584 +609 +440 +963 +55 +848 +125 +628 +285 +260 +137 +725 +760 +389 +431 +902 +859 +144 +967 +90 +736 +748 +35 +648 +753 +997 +428 +551 +287 +101 +335 +737 +642 +837 +129 +451 +459 +238 +650 +625 +83 +618 +204 +327 +451 +157 +506 +778 +70 +539 +304 +580 +972 +512 +294 +144 +443 +705 +957 +32 +676 +69 +270 +707 +132 +245 +33 +903 +353 +44 +628 +124 +48 +369 +809 +893 +279 +881 +834 +458 +748 +387 +740 +543 +861 +862 +330 +881 +516 +631 +488 +640 +627 +941 +725 +88 +998 +663 +828 +239 +325 +954 +287 +190 +658 +596 +285 +58 +339 +81 +615 +833 +79 +288 +776 +33 +656 +920 +450 +480 +820 +235 +21 +25 +464 +661 +342 +647 +186 +471 +341 +404 +401 +238 +244 +199 +470 +793 +690 +919 +340 +646 +119 +754 +647 +651 +464 +601 +209 +746 +493 +287 +87 +366 +35 +385 +696 +623 +216 +158 +586 +466 +805 +777 +889 +752 +106 +782 +125 +381 +361 +88 +391 +713 +625 +428 +989 +317 +26 +521 +165 +302 +891 +273 +618 +781 +93 +967 +897 +485 +840 +137 +789 +154 +56 +70 +833 +16 +821 +419 +338 +433 +214 +66 +51 +478 +567 +518 +779 +189 +69 +360 +992 +800 +803 +85 +41 +493 +980 +935 +858 +58 +910 +480 +667 +590 +610 +850 +158 +421 +296 +639 +623 +855 +996 +529 +381 +982 +408 +865 +183 +75 +749 +141 +609 +471 +814 +24 +407 +480 +611 +374 +417 +868 +400 +829 +667 +904 +218 +200 +376 +854 +884 +11 +474 +281 +509 +893 +493 +819 +830 +586 +920 +993 +561 +306 +222 +551 +141 +688 +109 +184 +232 +598 +827 +849 +874 +983 +950 +801 +849 +880 +574 +545 +323 +318 +61 +333 +338 +567 +263 +26 +453 +373 +103 +66 +99 +697 +835 +677 +635 +171 +617 +509 +790 +301 +404 +94 +913 +833 +902 +499 +392 +478 +248 +252 +690 +593 +178 +496 +897 +179 +481 +763 +997 +370 +202 +554 +178 +840 +294 +448 +344 +58 +846 +514 +80 +475 +113 +593 +137 +436 +921 +132 +552 +277 +272 +350 +497 +544 +245 +564 +477 +848 +374 +682 +424 +454 +104 +972 +220 +984 +31 +196 +490 +523 +430 +486 +170 +11 +100 +512 +109 +19 +969 +506 +332 +207 +207 +26 +607 +504 +617 +976 +263 +128 +830 +917 +832 +995 +106 +151 +836 +681 +218 +994 +298 +350 +276 +238 +973 +547 +413 +528 +389 +871 +720 +216 +848 +607 +125 +702 +373 +619 +32 +673 +845 +387 +70 +336 +923 +562 +382 +51 +801 +768 +316 +548 +784 +172 +309 +696 +395 +716 +641 +472 +968 +592 +218 +728 +785 +755 +936 +560 +166 +21 +326 +851 +793 +263 +544 +97 +612 +985 +613 +344 +367 +238 +772 +75 +486 +948 +364 +788 +872 +987 +169 +633 +685 +608 +588 +609 +666 +609 +469 +166 +74 +647 +454 +791 +222 +365 +729 +753 +95 +331 +493 +489 +50 +898 +334 +306 +774 +832 +543 +352 +873 +949 +146 +639 +168 +401 +490 +389 +453 +163 +272 +946 +621 +84 +599 +855 +324 +315 +637 +137 +826 +262 +231 +648 +514 +743 +777 +241 +354 +783 +359 +657 +970 +705 +295 +319 +36 +352 +272 +357 +671 +574 +95 +470 +510 +193 +248 +843 +538 +270 +200 +392 +85 +864 +829 +445 +370 +308 +476 +834 +792 +107 +49 +297 +254 +894 +51 +58 +351 +669 +810 +155 +72 +623 +521 +954 +232 +66 +234 +240 +431 +502 +861 +23 +460 +591 +207 +877 +187 +771 +609 +787 +146 +993 +85 +180 +855 +545 +937 +46 +747 +493 +388 +568 +876 +705 +83 +600 +367 +198 +731 +379 +411 +383 +916 +281 +68 +708 +217 +653 +325 +972 +612 +134 +198 +543 +204 +651 +608 +740 +464 +180 +598 +41 +802 +307 +478 +174 +40 +767 +158 +661 +714 +541 +88 +588 +813 +675 +353 +821 +464 +240 +520 +711 +818 +574 +500 +252 +227 +915 +32 +834 +336 +754 +98 +100 +529 +163 +89 +514 +401 +946 +46 +503 +11 +657 +574 +131 +793 +434 +98 +708 +139 +555 +832 +894 +158 +260 +212 +425 +861 +968 +336 +188 +497 +89 +733 +429 +412 +468 +816 +711 +410 +258 +290 +198 +890 +487 +304 +697 +897 +381 +931 +546 +132 +312 +935 +581 +35 +184 +918 +109 +354 +359 +914 +57 +428 +306 +484 +622 +245 +453 +779 +644 +944 +564 +146 +692 +941 +212 +51 +283