From e4ba9460414cb83f06dc446ec75ab04d82a6f0e2 Mon Sep 17 00:00:00 2001 From: David Vereb Date: Mon, 6 Dec 2021 22:32:30 -0500 Subject: [PATCH 1/2] Added part one of day four, plus a few 2020's from my laptop. --- 2020/1/a.out | Bin 0 -> 30320 bytes 2020/1/data | 200 ++++++++++ 2020/1/main.cpp | 43 ++ 2020/2/Makefile | 2 + 2020/2/a.out | Bin 0 -> 42256 bytes 2020/2/data | 1000 +++++++++++++++++++++++++++++++++++++++++++++++ 2020/2/main.cpp | 72 ++++ 2021/4/data | 601 ++++++++++++++++++++++++++++ 2021/4/main.py | 75 ++++ 9 files changed, 1993 insertions(+) create mode 100755 2020/1/a.out create mode 100644 2020/1/data create mode 100644 2020/1/main.cpp create mode 100644 2020/2/Makefile create mode 100755 2020/2/a.out create mode 100644 2020/2/data create mode 100644 2020/2/main.cpp create mode 100644 2021/4/data create mode 100644 2021/4/main.py diff --git a/2020/1/a.out b/2020/1/a.out new file mode 100755 index 0000000000000000000000000000000000000000..b0afe221e943379d684100d24243a53ca6b19808 GIT binary patch literal 30320 zcmeHQdw5(&b-#KzR)Qlb&nhI1*A5{HafDWu9XSt>Y_EMqBwJW^Vp5#D>($CyBJHZH zl_RIPm?%oU*(h}bqz2Mr3Z;V5VxTDk0?62n-Pc#~_^5zD1vueuYN(PBs#3%DcV^DH zd-rOu>%jN*>mM3>_spC*=ggTiXU@#dUd_HM)Um0&tjv&9VZ6zp(%cG-Y2}Ke3C;kt z8ZE}fcwcT@Yg~YGrNZg@Rt-?A(@c3WtYUlxAo0~vrUbl3qYZ(gAwlBvOOv&_MxeoE z;#)#h0eV9UsCNfGb%ibqbn~h9TAAJhn=jIMfo?vs&4Er`e_&TJ9OQnFFcdyA7x5it zzQfEXFu?W{DE1^B>D9vWyfA<|N&)q57+$`e%;$wdFHmgX{am`|*J-ay_*%6hEgtwR z4HS|4nkF>14d2MsU zP_m&(sX%&B8{|`)x9l*=4;WK~6Mm_uGSyQe9K9%Ag4cC;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FxL$=ww+Ss>5jLM=rNcBfaPeExIH&rT{>=)27I9DTK+ zitcB3D=)orZwh!%p!(&qYl+pgR6wGAiCEdiy}%WV4YY6$N=WqcC0%dr9vX7nqxe?` zyuF2w)2;4SbZA(Ayr7HY9Y6P54H1gH&v5c8^uNbz`Y`}mt5i=cY{X+Jy^+S&4iOiz zTdg|h^^*&QA4YJGqFi=g+?5hPL9lQ$<8fQe+fH1vAH!Aq_(hA*fWGWs2OPGP-oBpu zM>C2p?{Ag+^L01q@PtzNVN@1+%!xN084JdKhiqOsv8z1#)1QASak}0&~Cm3FZ zNqv6BqR76`{9L{qY+Se?o{OG+SNUS$hY5;DPlZ`uTRG7Mi@%E93xCkW=SNEx&NQ{! zc?F)c`J(=+U>v7S00l?<*oMb)*iZE)Q};(wJ@^2JT^s#^Mu|@j=mxLRGjAHnAQV4C;XdckGV}*{Ekp8XDl!m{f+Y#*cxzBiYVin;Mgz_!25{uSXEwhHpmQiX z3goXN7X1F4oc~B0d~7I1^_yKda(DP!Ds+{=fJ3P>I1VpLbdK%jm+y-O28yWZJICT= zqDW_ZqW=iDFK~v*@wJ9Z(!R*q2<*@CY=ZF1^BMxB|6YC;XKXB+NcarfF+!QkI_T{+^f!l?Up|}0715anyJk6Zv8szs4z4n&&1%4mAI0|?8N(c!@sJFMRFk=#H$D8h7bzyw*XfjI=9Q`ff$~ RE;xekAJC;MJPe+q@jtggUKaoW literal 0 HcmV?d00001 diff --git a/2020/1/data b/2020/1/data new file mode 100644 index 0000000..be449a5 --- /dev/null +++ b/2020/1/data @@ -0,0 +1,200 @@ +1778 +1845 +1813 +1889 +1939 +1635 +1443 +796 +1799 +938 +1488 +1922 +1909 +1258 +1659 +1959 +1557 +1085 +1379 +1174 +1782 +1482 +1702 +1180 +1992 +1815 +1802 +215 +1649 +782 +1847 +1673 +1823 +1836 +1447 +1603 +1767 +1891 +1964 +1881 +1637 +1229 +1994 +1901 +1583 +1918 +1415 +1666 +1155 +1446 +1315 +1345 +1948 +1427 +1242 +1088 +807 +1747 +1514 +1351 +1791 +1612 +1550 +1926 +1455 +85 +1594 +1965 +1884 +1677 +1960 +1631 +1585 +1472 +1263 +1566 +1998 +1698 +1968 +1927 +1378 +1346 +1710 +1921 +1827 +1869 +1187 +1985 +1323 +1225 +1474 +1179 +1580 +1098 +1737 +1483 +1665 +1445 +1979 +1754 +1854 +1897 +1405 +1912 +1614 +1390 +1773 +1493 +1333 +1758 +1867 +1586 +1347 +1723 +1285 +394 +1743 +1252 +320 +1547 +1804 +1899 +1526 +1739 +1533 +1938 +1081 +1465 +1920 +1265 +1470 +1792 +1118 +1842 +1204 +1760 +1663 +893 +1853 +1244 +1256 +1428 +1334 +1967 +1249 +1752 +1124 +1725 +1949 +1340 +1205 +1584 +548 +1947 +2002 +1993 +1931 +1236 +1154 +1572 +1650 +1678 +1944 +1868 +1129 +1911 +1106 +1900 +1240 +1955 +1219 +1893 +1459 +1556 +1173 +1924 +1568 +1950 +1303 +1886 +1365 +1402 +1711 +1706 +1671 +1866 +1403 +1816 +1717 +1674 +1487 +1840 +1951 +1255 +1786 +1111 +1280 +1625 +1478 +1453 diff --git a/2020/1/main.cpp b/2020/1/main.cpp new file mode 100644 index 0000000..985c9c8 --- /dev/null +++ b/2020/1/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +int find2(std::vector &numbers) +{ + for(auto i = 0; i < numbers.size(); ++i) + for(auto j = i + 1; j < numbers.size(); ++j) + if(numbers[i] + numbers[j] == 2020) + return numbers[i] * numbers[j]; + + return 0; +} +int find3(std::vector &numbers) +{ + for(auto i = 0; i < numbers.size(); ++i) + for(auto j = i + 1; j < numbers.size(); ++j) + for(auto k = i + 1; k < numbers.size(); ++k) + if(numbers[i] + numbers[j] + numbers[k] == 2020) + return numbers[i] * numbers[j] * numbers[k]; + + return 0; +} + +int main() +{ + std::ifstream ifs("data"); + if(!ifs.is_open()) + { + std::cerr << "Couldn't open file." << std::endl; + return -1; + } + + std::vector numbers; + for(std::string line; std::getline(ifs, line); ) + numbers.push_back(std::atoi(line.c_str())); + + std::cout << find2(numbers) << std::endl; + std::cout << find3(numbers) << std::endl; + + return 0; +} diff --git a/2020/2/Makefile b/2020/2/Makefile new file mode 100644 index 0000000..2f26a1b --- /dev/null +++ b/2020/2/Makefile @@ -0,0 +1,2 @@ +a.out: main.cpp + clang++ -std=c++14 main.cpp -g -O0 diff --git a/2020/2/a.out b/2020/2/a.out new file mode 100755 index 0000000000000000000000000000000000000000..d9b5c209b5930e18404d0297b12842bcbb240a5e GIT binary patch literal 42256 zcmeHw33yc1+5erHOct`TX%K-S42uD>K-fVE5S$>J1QBiRIGN0l)Fcx#lMt*Z6{EzM z7OdOnN?X^~ukKb+E7k>U>sM-9OKWRst98;%O0A`~mH+Seo^xhyhNO?u^6&RO5BJI3 z_nhCmocFxv+;h)4_h#nus^v?a4u@q9mvy?u+<~zQS*RHWx9J4PLTk2_i?i1nXQd;b zCYa(cR0Ldg?05F1nHqP2Qm>GSe(0$RwhT2Ml2UJ=WA@AS}&Cvc|%R?Yu=949ZPwuwO*NyV=6V>%urL_+0bKLKI);H z-CCo|8>k&RbUY1ZKjBf@*ibvOqO`GYYGXrlTgTLn*)ylktSE^_N~Q^)ez6SpsWVre zV>!22yNMZn!)Km+9>n9KqWPE7%6nxnCb+@#}AkAY0J|29s@EL`V z^l4E0!KP%jj4$Mw_Ga3C+c{G9U6j z>TwkuWtpkR7F41?ymA2iT{u>hY6SUr@#)XbI|JC62Rr@AUp@f-vjOl22e4m^AoXYe zg8}gG3}AoR0C9VF0DS2HacF~mJ!JNYUiJWX9v{HYxB>k9%>ejI1JrlQ0CD^30Oj&p z@!*qsJUc+S7Y$JEhXcq%ykGlM2EZ={-e3Fv_W9Ic7?w# z)Ee5*5RHXe*RELH7-q$shDfwJSQ9HR57q}-{jt_S zLkvJwRj|Fbs@?LRzp^Ga%kK|%bd;BuPg5$|;NMp3B;n-{} zE|=14Vilq0y2k#>s#*iDrz?*la48gMs$T0~TjsB-nT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Rl$C0S`+)f4o5=Rx>CtLUaC zELTABqLI*glfo1GP-}}-BC8_2rCQR`ir&*2+oU1%kEwi>rG&hC?pl}BZEA)+Me)jp zaP&7r_sRIdYYjC9sGw6VjWMf)s|KqC?_c38U8JNnBJ=W+P`zH8)Yn1RP*)VAo6=-S*LIrPo@l+y3D)SgXtP-rAn)s@2iM$quYdah<=|F95YpC7iWY=6v zAzB8;^X?5;n*Cc2eiZ<=D6q$#x`PhI)*krr74{bNG!R;(Pp!oS_$i&+o`Ld7sudbi3B4TlCZTuVL#FBp6GhZ@#DBQ1d`)$L!Sl9$kNZ zStt6h@#{~}W&Mr*?p4U(*v;>(#j#M%$&)G9(8FNa^%Ku=wBo*`s-%pbp$;h9_09hE zKCN%AGh@c+nS2J6i5dUR{(W5Qr^>S|`;nu|*WD(;GWrt}h)NiJLx*eq6frBmQXv^d zeK|(YpkoKnKPjjrBBo+mAyvP00R7IeQn)rH0IB-(w0>&+2S=3tYy3BM+hOz#U8?nM zB9i>ol?pkK!Z3OUW +#include +#include +#include + +// 6-7 w: wwhmzwtwwk +bool Valid1(const std::string &str) +{ + int min, max; + char letter; + std::string password; + + auto dash = str.find('-'); + auto space = str.find(' '); + auto space_two = str.find(' ', space + 1); + + min = std::atoi(str.substr(0, dash).c_str()); + max = std::atoi(str.substr(dash + 1, space).c_str()); + letter = str.at(space + 1); + password = str.substr(space_two + 1); + + // std::cout << "min: " << min << std::endl + // << "max: " << max << std::endl + // << "letter: " << letter << std::endl + // << "pass: " << password << std::endl; + + int total = std::count(password.begin(), password.end(), letter); + + return (total >= min && total <= max); +} + +bool Valid2(const std::string &str) +{ + int min, max; + char letter; + std::string password; + + auto dash = str.find('-'); + auto space = str.find(' '); + auto space_two = str.find(' ', space + 1); + + min = std::atoi(str.substr(0, dash).c_str()); + max = std::atoi(str.substr(dash + 1, space).c_str()); + letter = str.at(space + 1); + password = str.substr(space_two + 1); + + bool a = password[min - 1] == letter; + bool b = password[max - 1] == letter; + + return a != b; +} + +int main() +{ + std::ifstream ifs("data"); + if(!ifs.is_open()) + return -1; + + int valid1 = 0; + int valid2 = 0; + for(std::string line; std::getline(ifs, line); ) + { + if(Valid1(line)) + ++valid1; + if(Valid2(line)) + ++valid2; + } + + std::cout << valid1 << " valid1 passwords." << std::endl; + std::cout << valid2 << " valid2 passwords." << std::endl; + return 0; +} diff --git a/2021/4/data b/2021/4/data new file mode 100644 index 0000000..ba441b7 --- /dev/null +++ b/2021/4/data @@ -0,0 +1,601 @@ +42,32,13,22,91,2,88,85,53,87,37,33,76,98,89,19,69,9,62,21,38,49,54,81,0,26,79,36,57,18,4,40,31,80,24,64,77,97,70,6,73,23,20,47,45,51,74,25,95,96,58,92,94,11,39,63,65,99,48,83,29,34,44,75,55,17,14,56,8,82,59,52,46,90,5,41,60,67,16,1,15,61,71,66,72,30,28,3,43,27,78,10,86,7,50,35,84,12,93,68 + +90 8 2 34 41 +11 67 74 71 62 +47 42 44 1 17 +21 55 12 91 6 +60 69 75 92 56 + +49 29 60 45 31 +94 51 73 33 67 +21 92 53 95 96 + 2 55 52 8 87 + 4 36 76 83 42 + +23 66 50 84 58 +62 98 81 76 57 +24 2 56 79 6 +55 0 16 64 38 +12 67 5 97 60 + +46 64 5 39 62 +16 82 13 77 52 +18 26 44 0 61 +25 7 43 42 50 +11 85 30 28 76 + +51 28 70 65 78 +62 88 30 36 96 +80 87 4 1 24 +63 22 41 79 34 +18 15 47 26 67 + +48 68 92 67 36 +54 50 71 98 21 +20 91 70 78 76 +87 97 44 3 93 +84 12 39 96 57 + +86 12 38 44 1 +10 87 74 53 66 +14 99 85 48 88 +59 33 76 71 31 +83 39 2 67 35 + +62 67 27 96 8 +81 23 78 33 48 +80 16 0 86 85 +26 54 29 32 89 +88 77 43 18 46 + +87 88 13 49 80 +78 19 81 56 11 +18 55 70 44 48 +31 37 24 95 28 +20 79 89 94 14 + +10 31 52 49 79 + 8 72 61 27 42 +73 4 11 43 91 +37 44 58 19 97 +96 63 90 13 74 + +71 27 87 40 99 +69 29 79 64 67 +85 66 4 28 30 +23 51 16 49 45 +92 12 74 1 75 + +46 52 40 12 44 + 0 73 20 86 1 +85 32 4 42 2 +21 33 56 39 9 +49 69 76 98 22 + +42 81 5 11 2 +57 50 77 8 24 +85 92 15 39 52 +37 70 36 79 67 +34 20 16 93 22 + +49 68 25 4 46 +17 57 77 59 54 +65 83 18 84 63 +36 74 61 22 71 +14 0 26 3 98 + + 1 80 93 66 58 +38 9 18 60 2 +70 46 35 88 11 +95 89 85 29 26 +82 68 25 15 53 + +97 80 28 17 7 +67 46 54 95 98 +38 74 42 57 79 +63 29 36 78 6 +90 60 84 10 14 + +18 88 8 96 0 +66 56 43 47 11 +69 73 14 71 25 +27 63 31 44 94 +75 95 84 74 13 + +92 9 98 17 74 +46 7 2 51 52 +21 60 5 87 15 +86 91 65 69 54 +61 85 1 62 53 + +89 80 4 0 68 +17 87 52 86 48 + 3 34 16 25 35 +13 38 49 66 50 +36 43 65 84 56 + + 9 93 54 92 55 +32 2 39 96 98 +58 72 52 83 97 +12 44 27 24 20 + 0 3 28 56 69 + +66 56 37 36 72 +35 49 40 43 44 +54 21 59 12 65 +74 25 22 80 98 +27 81 69 97 62 + +72 81 27 61 74 +26 50 79 13 53 +49 78 76 70 43 +51 64 99 46 67 +68 59 71 17 41 + +97 22 73 30 98 + 8 54 68 47 23 +70 89 41 52 61 +81 28 58 90 3 +88 40 86 46 43 + +94 6 46 43 59 +41 28 87 31 45 +83 26 66 81 1 +76 86 15 42 8 +67 47 54 4 77 + +96 56 22 67 2 +95 47 90 54 51 +78 79 29 82 48 +61 81 77 6 24 +71 93 98 26 75 + +95 7 77 94 64 +19 79 14 24 5 +50 48 4 71 22 +35 69 89 54 2 + 6 51 8 82 58 + +87 6 85 53 64 +50 43 80 61 15 +69 41 51 76 0 +78 26 37 62 16 +12 33 75 58 52 + +67 18 68 52 42 +37 30 49 31 69 +93 90 76 9 32 +60 84 73 94 17 +21 27 66 43 44 + +89 69 24 14 1 +88 33 50 2 63 +12 34 6 97 53 +28 26 55 8 32 +49 19 17 64 86 + +31 37 81 65 38 +96 18 45 19 58 +35 43 1 49 41 +46 85 92 53 15 + 3 34 8 14 21 + +35 68 61 45 39 +46 99 52 55 15 +74 14 10 62 17 + 8 66 98 89 91 +58 24 44 27 29 + +28 48 52 18 13 +17 35 20 11 49 +93 50 31 95 83 +27 33 79 44 80 + 4 96 23 65 68 + +70 78 31 86 36 +99 38 62 95 27 +52 74 25 80 41 +30 15 47 19 21 +77 23 53 9 7 + + 0 83 11 25 42 +50 64 76 67 72 +75 30 82 15 84 +58 17 87 61 33 +98 74 44 3 93 + + 5 40 78 24 11 +57 17 67 60 25 +37 76 28 56 35 +66 94 2 90 47 +86 10 85 46 45 + +63 12 7 74 14 +21 31 84 51 36 +66 20 25 46 41 +15 3 18 62 45 +35 78 93 2 9 + +90 9 33 63 41 +25 73 35 97 19 +99 96 45 71 22 +84 43 29 14 88 +42 8 1 78 68 + +98 84 38 95 27 +18 32 54 12 96 +56 50 2 45 53 +14 83 59 72 70 +22 41 28 9 78 + +89 94 50 33 73 +31 47 8 35 34 +43 92 95 21 51 +68 13 53 24 38 +80 69 44 87 83 + +32 82 75 73 91 +99 10 22 58 23 +86 9 42 81 40 +71 25 3 78 54 +80 15 83 5 4 + +58 1 3 11 24 +66 51 84 44 25 +37 54 12 27 97 +38 2 39 85 83 +89 91 33 79 59 + +49 22 12 84 60 +34 29 11 92 19 +97 41 88 53 38 +26 37 8 36 67 +91 3 90 52 46 + +77 35 76 56 20 +39 94 37 3 83 +78 81 66 29 4 +82 41 38 0 73 +59 16 88 15 30 + +34 69 74 90 33 + 9 47 71 94 10 +76 50 15 19 32 +49 89 31 21 92 +80 12 13 97 93 + +45 94 35 59 20 +18 46 14 36 30 + 6 78 84 38 99 + 5 4 90 92 63 +34 24 26 75 3 + +80 39 1 93 55 +67 71 30 44 76 +38 13 73 21 8 +11 47 46 69 29 +15 57 95 52 34 + +45 86 88 80 19 + 3 5 55 36 90 +54 85 44 18 39 +57 92 42 25 77 +43 0 12 1 24 + +74 71 83 29 25 +56 12 52 33 64 +68 94 97 14 15 + 7 48 24 80 5 +54 87 35 1 66 + +55 50 73 72 36 +17 80 87 68 90 + 8 33 81 1 51 +67 61 71 54 95 +93 98 27 56 0 + +19 32 63 6 98 +13 38 23 28 8 + 5 31 66 72 39 +99 46 2 64 14 +91 83 35 85 10 + +67 85 49 68 37 + 8 36 31 81 18 +74 61 20 80 50 +34 23 42 52 39 +21 14 22 58 54 + +16 14 69 13 81 +21 96 62 7 5 +95 52 0 67 24 + 6 30 65 66 86 +28 25 85 56 15 + + 4 41 21 86 32 +95 23 63 28 2 + 9 16 37 84 14 +92 22 71 42 5 +46 65 69 81 57 + +45 20 46 44 22 +62 93 78 58 25 +91 38 29 68 24 +21 55 71 43 26 +64 76 84 80 99 + +92 67 43 5 12 + 2 64 46 15 96 +95 75 73 38 30 +10 65 20 39 26 +36 16 25 27 88 + + 9 62 18 58 34 +85 80 36 2 48 +16 60 75 72 51 +39 22 32 61 54 +40 44 23 87 53 + +93 69 56 4 22 +73 51 24 53 19 +83 98 77 94 59 +52 70 15 40 48 +60 89 67 92 85 + +48 72 42 80 22 +99 49 11 77 4 +28 24 1 63 51 +85 93 62 7 78 +35 32 3 21 86 + +36 75 67 79 34 +20 8 71 6 5 +50 61 14 52 81 +26 37 0 80 77 +93 47 86 54 94 + +50 19 68 54 80 +81 12 33 87 24 +28 40 37 30 31 +41 51 15 27 97 +67 70 14 77 86 + +89 57 48 37 27 +44 46 29 63 20 +74 88 25 68 76 +18 28 91 59 58 +99 77 62 64 83 + +22 5 86 37 42 +47 69 87 34 89 +64 33 18 56 51 +30 49 11 79 17 +61 80 0 29 57 + + 7 82 87 15 83 +76 43 92 1 97 + 0 46 2 86 6 +48 27 29 61 67 +53 10 64 93 77 + +65 16 23 26 87 +58 5 25 97 94 +43 7 39 69 35 +62 81 56 13 28 +76 12 37 14 93 + +90 81 15 55 23 +58 40 8 56 76 +83 7 78 89 47 +65 70 13 48 42 +16 69 66 52 46 + +30 38 20 32 94 +91 96 34 23 90 +16 24 49 50 86 +65 19 56 7 66 +80 60 74 71 11 + +60 77 54 25 22 + 9 61 68 6 89 +15 71 10 84 41 + 1 47 8 43 63 +69 57 85 24 81 + +54 83 73 52 49 +69 96 31 57 44 +19 66 24 6 55 +91 84 20 3 27 + 7 9 71 43 75 + +90 72 15 99 2 +73 56 48 28 62 +40 75 0 59 31 +43 67 44 24 77 +98 35 4 3 37 + + 2 85 72 39 49 +58 25 91 69 19 +34 8 57 42 55 +80 21 51 64 30 +28 32 82 84 6 + +33 77 39 13 12 +86 21 96 82 94 +78 92 42 45 70 +31 22 60 80 67 +79 27 93 55 65 + +49 90 73 72 10 +98 89 77 88 12 +83 3 31 47 21 +65 26 93 55 53 + 5 95 22 8 63 + +79 88 11 62 25 +85 14 77 4 19 +41 31 83 26 67 +46 98 74 99 2 +44 53 70 36 52 + +21 33 15 57 53 +56 91 25 69 10 +52 59 73 96 87 +65 71 14 37 2 +39 89 29 83 64 + +88 38 45 39 20 +99 72 61 96 4 +23 24 67 49 80 +77 6 65 76 18 +59 51 78 33 46 + +44 22 9 90 83 +93 50 2 54 26 +68 71 43 85 41 +38 20 6 64 24 +81 39 33 56 27 + +98 1 69 30 38 +67 52 79 31 0 +24 41 82 55 73 +33 66 64 20 7 +65 9 14 70 94 + +59 63 65 25 1 +36 85 61 82 50 +52 3 70 30 43 +79 57 31 71 76 +19 97 93 77 49 + +60 45 90 32 74 +77 64 58 44 43 +71 49 37 21 46 +50 67 1 24 15 +14 22 0 40 23 + +65 87 81 64 28 +53 80 23 76 77 +49 14 50 2 35 +85 26 88 94 30 +79 18 68 15 45 + + 6 48 38 63 92 +51 45 58 4 76 +78 40 22 17 55 +79 12 66 61 5 +68 74 0 93 89 + +66 4 65 71 77 +47 35 38 83 64 +53 16 9 56 25 +92 81 55 60 33 +80 24 73 0 26 + +26 29 55 76 38 +79 52 91 84 39 +50 57 37 34 71 +33 31 68 92 24 +81 95 5 70 8 + +83 64 11 67 42 +97 29 27 4 78 +23 10 48 71 81 +80 74 86 17 36 +61 14 85 21 96 + +18 8 7 88 25 +59 5 28 57 69 +64 54 16 70 72 +13 75 71 33 2 +60 55 46 51 32 + +23 89 63 96 88 +71 66 9 53 65 +56 46 29 95 80 +44 94 90 3 5 +11 99 59 60 78 + +42 33 81 25 0 +46 66 63 82 94 +52 73 92 30 24 +59 26 50 87 45 +79 55 74 17 64 + +95 43 13 98 18 +62 12 24 88 28 +23 11 93 51 67 +71 0 44 64 96 +66 17 84 90 19 + +38 6 12 75 27 +28 73 62 50 51 +63 86 29 98 15 +46 90 4 58 96 +20 78 64 56 82 + +19 91 23 40 1 +78 57 75 43 2 +35 60 85 74 30 +80 3 63 54 32 +82 99 89 25 88 + +88 13 92 11 72 +56 6 35 55 21 + 8 20 36 60 99 + 1 96 57 45 12 +41 73 50 83 69 + +42 69 53 76 11 +38 74 13 14 86 +18 49 51 67 61 +26 80 47 16 78 +66 46 12 68 79 + +22 90 72 93 24 +55 29 43 28 5 +99 47 87 40 51 +81 18 70 20 36 + 0 48 23 46 82 + +91 74 83 95 54 +60 56 38 37 89 +87 96 71 50 35 + 5 11 42 72 3 +77 81 36 49 97 + +71 72 17 34 93 +45 81 22 67 23 +61 20 94 14 1 +85 40 15 36 88 +54 91 62 73 9 + +66 36 39 58 60 +96 8 22 49 77 +76 64 47 78 30 +50 41 12 69 15 + 7 1 29 72 27 + +90 12 65 13 39 +75 70 47 36 79 +31 54 17 10 32 +76 92 55 83 40 +49 5 20 44 37 + +16 78 65 5 70 +63 72 89 93 66 +21 90 46 54 81 + 7 48 88 60 11 +95 0 38 3 26 + +19 65 66 41 27 + 7 18 91 52 48 +87 55 49 68 71 +85 12 4 40 1 +57 67 6 11 58 + +91 85 38 14 21 +63 93 37 76 25 +68 36 4 24 71 +43 31 60 19 95 +52 55 13 83 78 diff --git a/2021/4/main.py b/2021/4/main.py new file mode 100644 index 0000000..eb5937c --- /dev/null +++ b/2021/4/main.py @@ -0,0 +1,75 @@ +# all the numbers called, in order +numbers = [] + +temp_board = [] +boards = [] +fills = [] + +board_index = 0 + +#### +def Victory(board): + for y in range(0, len(board)): + if(board[y] == [True, True, True, True, True]): + return True; + + # NOTE(dev): Assumes all columns are the same length + for x in range(0, len(board[0])): + num_true = 0 + for y in range(0, len(board)): + if(board[y][x]): + num_true = num_true + 1 + if(num_true == len(board[0])): + return True + + return False + +#### +def FindWinner(numbers): + for i in range(0, len(numbers)): + for board_index in range(0, len(boards)): + for y in range(0, len(boards[board_index])): + for x in range(0, len(boards[board_index][y])): + if(boards[board_index][y][x] == numbers[i]): + fills[board_index][y][x] = True + if(Victory(fills[board_index])): + print('Victory with', numbers[i], 'on board', board_index, '!!') + return numbers[i], board_index + +#### MAIN EXECUTION #### +with open('data', 'r') as fp: + for i,line in enumerate(fp): + + if(i == 0): + numbers = line.strip().split(',') + elif(len(line.strip()) == 0): + if(len(temp_board) > 0): # i.e. skip the first, empty one + # add in the next player board + boards.append(temp_board) + temp_board = [] + # create a blank answer board for this player board + for j in range(0,5): + temp_board.append([False, False, False, False, False]) + fills.append(temp_board); + temp_board = [] + board_index = board_index + 1 + else: + # add the next array of numbers to the temporary board object + temp_board.append(line.strip().split()) + +winning_number,winning_board_index = FindWinner(numbers) +print('Winning Number:', winning_number, ', Winning Board Index: ', winning_board_index) + +total = 0 +for y in range(0, len(fills[winning_board_index])): + for x in range(0, len(fills[winning_board_index][y])): # assumes size is same for all columns + if(not fills[winning_board_index][y][x]): + total = total + int(boards[winning_board_index][y][x]) + +print(total * int(winning_number)) + +# # DEBUG(dev): Show full contents of all boards +# for x in range(0, len(boards)): +# for y in range(0, len(boards[x])): +# for z in range(0, len(boards[x][y])): +# print(boards[x][y][z]) From 584618a34999bbd342f98ee005e07cbbde2fa4ef Mon Sep 17 00:00:00 2001 From: David Vereb Date: Mon, 6 Dec 2021 22:58:06 -0500 Subject: [PATCH 2/2] Added part two for day four, though it's missing quite a bit of error checking. --- 2021/4/main2.py | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 2021/4/main2.py diff --git a/2021/4/main2.py b/2021/4/main2.py new file mode 100644 index 0000000..0cd11a0 --- /dev/null +++ b/2021/4/main2.py @@ -0,0 +1,83 @@ +# all the numbers called, in order +numbers = [] + +temp_board = [] +boards = [] +fills = [] + +board_index = 0 + +#### +def Victory(board): + for y in range(0, len(board)): + if(board[y] == [True, True, True, True, True]): + return True; + + # NOTE(dev): Assumes all columns are the same length + for x in range(0, len(board[0])): + num_true = 0 + for y in range(0, len(board)): + if(board[y][x]): + num_true = num_true + 1 + if(num_true == len(board[0])): + return True + + return False + +#### +def FindWinner(numbers): + indexes = [] + winning_indexes = [] + for i in range(0, len(boards)): + indexes.append(i) + for i in range(0, len(numbers)): + for board_index in range(0, len(boards)): + if(board_index not in winning_indexes): + for y in range(0, len(boards[board_index])): + for x in range(0, len(boards[board_index][y])): + if(boards[board_index][y][x] == numbers[i]): + fills[board_index][y][x] = True + if(Victory(fills[board_index])): + print('Victory with', numbers[i], 'on board', board_index, '!!') + winning_indexes.append(int(board_index)) + indexes.remove(int(board_index)) + if(len(indexes) == 0): + return numbers[i], board_index + +#### MAIN EXECUTION #### +with open('data', 'r') as fp: + for i,line in enumerate(fp): + + if(i == 0): + numbers = line.strip().split(',') + elif(len(line.strip()) == 0): + if(len(temp_board) > 0): # i.e. skip the first, empty one + # add in the next player board + boards.append(temp_board) + temp_board = [] + # create a blank answer board for this player board + for j in range(0,5): + temp_board.append([False, False, False, False, False]) + fills.append(temp_board); + temp_board = [] + board_index = board_index + 1 + else: + # add the next array of numbers to the temporary board object + temp_board.append(line.strip().split()) + +winning_number,winning_board_index = FindWinner(numbers) +print('Winning Number:', winning_number, ', Winning Board Index: ', winning_board_index) + +total = 0 +for y in range(0, len(fills[winning_board_index])): + for x in range(0, len(fills[winning_board_index][y])): # assumes size is same for all columns + if(not fills[winning_board_index][y][x]): + total = total + int(boards[winning_board_index][y][x]) + +print(total * int(winning_number)) + +# # DEBUG(dev): Show full contents of all boards +# for x in range(0, len(boards)): +# for y in range(0, len(boards[x])): +# for z in range(0, len(boards[x][y])): +# print(boards[x][y][z])