diff --git a/2020/1/a.out b/2020/1/a.out new file mode 100755 index 0000000..b0afe22 Binary files /dev/null and b/2020/1/a.out differ 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 0000000..d9b5c20 Binary files /dev/null and b/2020/2/a.out differ diff --git a/2020/2/data b/2020/2/data new file mode 100644 index 0000000..5f2459a --- /dev/null +++ b/2020/2/data @@ -0,0 +1,1000 @@ +6-7 w: wwhmzwtwwk +10-12 q: qqqqqqqqqqqdqqq +16-17 d: ddddgdddddkddddsxddd +2-4 q: shbqwqpps +3-4 q: qkfq +2-10 m: bkdrmcfdhmr +13-19 s: blccvhsgsnsssqszssm +1-3 l: qlxllhl +4-6 h: hhhqhhh +15-17 l: jrtllrlllllmmlllg +11-12 n: bnzlnnnnbnntnnnc +1-7 p: pppvppjppmptp +5-6 t: tttnht +8-12 g: glbnlqgggjkh +1-8 g: dvgsggngg +13-16 x: xxxzxxxxxxnxjxxxx +6-9 m: ffmwhxxsm +10-11 b: bclbkkxblbbb +5-7 m: mtmmbmmm +2-4 c: cdgdkcd +9-15 f: ffffffffpfffffbffff +2-3 k: kkkqk +12-13 s: ssssssssssssgs +13-15 d: ddddddddddddcdqd +3-10 g: vpgqrvqnlpgjd +12-16 x: zrrxjxvvrcnkwklddm +2-6 g: lgjwpg +17-18 b: bblsjbkrbbbrknmgbx +3-5 c: ccpmcsvfxlhgbgccccxw +3-6 x: zsxrhxnptxtwwbbb +18-19 h: hhhhhhhhhhhhhhhhhcbl +12-13 h: hhlhnqdhttwhqcwdd +17-18 c: cccccccccczcccccfcc +9-19 h: shhhbhhhhtwhkhnbhfp +7-11 c: tntwmfzdncchszl +5-8 x: pxmkxmzbbvfldpwc +3-6 n: rmwnqnlt +5-11 z: zzhzkzzzzzq +3-4 v: vwvdb +6-9 t: ttttctttb +4-5 h: hhbzc +2-4 c: cccpccmpcp +6-7 w: wwwwwhwwj +4-9 g: qgbwsqlgg +2-4 c: cddc +6-13 r: bqxjlrdrgdjlhcpqp +9-15 f: qqflwbjgffwfxkv +8-11 t: txtstwzrggtcrtttmpp +6-11 m: mmmmmlmmrmmmm +7-13 c: ccsbbcccmckpzrsncbvz +6-8 v: vvdvdrvkv +8-11 h: mhhhvshhthhhhtmshhh +1-5 k: ckkkkk +2-3 v: nhvvqnvlz +13-16 z: zzzzzzzzzzzzzzzfz +2-3 k: gkrj +16-17 h: hhhhhhhhmghhhhhhrh +3-4 c: cccs +3-4 s: ssssssssss +2-4 r: rlrg +10-11 d: ddwdddddddz +7-12 c: pllhkcgrkmcmxqwccclv +8-9 b: bbbbbbbbg +11-20 b: bbdbbrbmjbbbxsbgzbsm +2-4 m: mmqmmfthp +8-13 w: fwgjkfwwfcbpwbh +4-10 t: tttttttttqtt +11-15 k: pkbmgkkkkkrkkkkkkpkk +9-10 k: mkkkkkkkkg +16-17 b: bbbbbbbbbbbbbvbbt +12-14 h: hhhhhhhhhhhphhhhhh +5-17 z: knzcjlgjlkvglrsqzwt +4-6 s: vwpjsds +1-4 j: jjqgnqq +2-3 b: bbhb +1-6 k: kgkkkkkvjkkkgjkk +8-11 d: dddddddnddd +5-10 w: hdbcwwqltq +5-6 t: tttttttt +2-6 l: lllllqlllclgltllj +2-5 k: kjkkckkhdkkkn +12-15 l: llvlllllllljplw +1-3 d: ddnddddcdd +8-14 b: vbdbfbhsjbbgbpsbq +9-12 z: zzzzzzzzxzzzz +2-3 w: swmt +17-18 z: pfpzprvxdzvkzzhxpz +9-10 p: lpqppppspjprmppnp +18-20 r: rrhrxrwkrfrrhgkmftrr +5-7 x: ppkbxxp +2-13 s: skqtnddznmqlsjfn +14-17 l: cdlkcxpvjghdnlllqt +3-9 t: pttlpbdhtvtkjgh +1-6 b: zbbbbv +1-3 r: vrqr +7-19 h: hhhhhhqhhhhhhhhhhhsh +11-17 g: gfgmsggzggpgbgggggg +15-18 b: btzwbbpbsbmvrbbjncb +6-9 b: bbvbcxxbbbprbbbcxqvp +4-5 r: kqrhh +5-12 n: ncnnnmnnmnnf +8-9 p: nnmmbqcprcbppzgdjft +6-8 h: hhrhhjhh +1-6 t: ltjmrtttttnzjtcttv +5-6 g: gvgwgkgg +4-8 q: znlthvfskq +1-7 q: qpqdrzq +3-4 z: xsqztkz +2-5 w: bwwwrjww +3-15 k: kkrkkkkkkkkkkkpkk +1-4 z: pzbzztkv +2-4 h: nhbg +1-6 q: hwntnqpwhcqknpfkqn +12-14 p: ppdhllppptjcgp +6-11 k: kkkkktkkkkkk +10-12 f: fjffzrfqffcfzfcf +1-6 m: lzmmmz +18-19 z: zzzzzzzztzzswzzzgxzz +1-3 g: ggbfxgg +1-3 c: xgcwxmtzjvlcp +8-10 z: zzlzzzpbzdzz +1-9 s: qpsskgwsssvksfvxsss +7-9 j: tqxjtjddjjjjjjh +4-17 h: xhhfhhhhhhthhhhhhhh +11-13 n: nnnnnnnnnnsnnnnnnn +12-14 j: jxjjjjjjjjljjd +11-15 q: qnprkqtqcntttqqwgqx +15-16 h: hhhhhhhhhhhhhhbhh +3-4 w: wwtw +2-8 n: wqnnmngnnjnnnnv +5-6 k: xbkrklb +3-7 l: lrvlrlllfhslsl +10-17 t: fhltmsgptmhckrvkttzs +8-9 k: kkkkkkkxd +7-9 d: dddddfddddkd +8-11 m: mgdmmmmmmprmmm +5-16 s: ssssmsssssssssssssx +2-3 k: kkmk +2-10 m: mfmmmmmlcmjwm +9-10 k: kkkkkkkkxkk +8-9 l: jkzdnljrlgnf +2-3 h: vdhlhpcdsh +8-13 h: hhhhhhhphhhhhhhh +13-18 k: kkrkkxkkkkkkrpkkkkk +1-3 t: rttptklrtvtp +8-13 s: jhssbsssssslb +16-18 v: zpfwlvcdbjpcxfhvtlrv +5-7 j: jfmjljj +5-10 c: cgctckffldkcjd +10-11 k: kkkkkkkkknk +10-12 g: rggggggggggwg +12-13 n: nknnnnnnnnnnnn +2-4 c: vdccccf +2-5 b: hblbb +1-4 m: spmm +12-16 s: shsssssssrssgssdss +10-11 x: xxxxxxxxxxpx +2-17 z: xzjmjdclpdtqjhhqm +4-5 j: qjljz +1-2 t: ftttr +4-5 k: krnktrmjvkcqdwm +11-12 n: nljwhlkpdknfl +12-13 x: xxxxxxxxgxxxj +5-15 j: jjhvjjjqjljpjjkjj +3-5 w: hqwkmmqddbncznm +5-14 l: lllllllllllllll +9-20 z: vvfmxfbpzzgmcclhgzzz +8-9 x: xxxxxxxbjx +5-6 m: mmkvmgdmm +1-13 x: qkxlvzxxxxxxxbnx +7-8 r: rsrrrrbrlrr +2-3 r: lrndhwcbxf +4-8 q: qqqqqqqwq +6-11 g: bxzlpftzfwk +1-3 k: hlkwkgh +4-6 c: hmchdm +2-8 d: ddgbxrfc +2-7 b: tnmtcbbrwnvwsmfmd +17-18 p: btpppwcxppqpspppwp +13-17 d: dddddxzddddddddddxd +5-11 z: zfvzzzzzzzpz +5-14 z: zvkzqzzzzzzdzpzzzzz +4-7 n: nnwnqntnmnn +1-6 l: blllllllll +11-13 f: fmffffflrfzfpf +3-11 v: zqvbjxvjvbvnsznkm +7-8 b: wqbbpcbb +1-4 s: jzvwscxzsd +2-5 w: wwtpn +1-3 k: mklk +6-7 v: vvvvvvv +4-5 n: gnnlclqbnwgngzc +7-14 w: scdwgdzljgdwmww +9-10 b: brmnhptdwblr +5-12 t: tchrszgdttmpvntwdpv +12-14 j: vjnzjjppjwhjnrpj +5-6 h: rmjhfhdh +2-7 h: hbptmhhh +5-8 n: dszknnnnrbxc +13-15 p: pkpwdnqvkdxtkppcdtrp +1-8 s: sjssssshss +1-2 p: pbtprdj +3-18 k: nkkkqkkkrkkkkmkvkkmk +15-16 w: wmwwwzwbwwwswwqswwrw +7-12 d: dsdzddvddddjldddcxd +10-11 r: msjrgbrgrlr +1-2 t: tttltpqtqzt +3-4 n: nxwnpnk +11-12 k: jkkkkkjlkzfvxzkk +6-7 m: mmmmmmz +4-6 r: rbghdr +2-4 k: kqqkxkktkxkkk +7-9 t: jlfttntttdt +5-6 t: sttttzk +5-11 v: vvvvvhvvvssvvgvfv +4-5 m: mmmqm +13-16 r: rrrqrrrrrrrrrrrpr +3-5 t: pdrhtt +2-7 x: zgkxxxxszmhvb +5-6 q: qqdbzd +3-5 g: gxgst +6-14 g: zslgrmgrgjgglg +12-13 q: qqqrfqqqqqqqqqqqqx +2-3 r: lrrr +5-6 n: qnnnfnnn +4-5 w: wwwwmw +1-8 h: hhhhhhhhhhhhhh +3-4 k: kkrcfqxvqhqxzvkkt +7-13 s: tsrmwckktjnqslm +2-17 r: rrrrrrrrrrrrrrrrhr +4-6 q: qqqqqdqqq +18-19 m: mzxmzpmccmcmmmmmtmm +5-11 m: cmmmlmmmhmsmmmmm +17-18 j: blqwsqcjjjfrjrjzwh +2-19 s: zsmzkcvcmjlsfwfzqmcn +2-7 g: bgjkglnqnf +5-11 n: qcxpjnfnnnnnhjvn +4-5 r: cwzrrpmwwbrkbrrcr +5-6 n: nhthvnfngd +10-11 b: xsvrvbvnhbn +9-11 j: jkjjjmjjjrkjmjv +4-5 v: kvvvw +4-5 s: scnfs +3-4 n: bmff +1-9 r: rvnfbzklr +7-9 h: hmbhhhhhhh +2-8 d: dddlddddddddd +3-5 b: vxbbp +3-6 j: jjzjjj +3-4 q: qqrq +7-17 s: vssrsswsssqssssvsvws +15-16 x: czxkgcfwxdxxmxxx +1-11 f: jdxfccfbvffmh +1-5 r: rrrrkrrrrj +3-5 k: kkzklkkk +3-9 f: hxqfffpfff +13-17 q: cqtqqqgqkzqqqqqqjwq +4-5 r: srwdtrr +3-4 c: ccnc +10-12 d: ddddfdddgtdg +4-9 k: kkkkkhlkkkkkkk +6-7 q: rtgqnqxpnq +11-14 v: mhnvnjthhfvvwvnzjjrj +9-11 b: mxzvbwvrqvb +7-8 z: zzzzzzzzzzz +8-12 z: bstjbngzfqppdvgwxddk +3-5 m: tgmvv +1-4 d: ddsxbxkmxhxrhstz +7-8 w: wwqrwwrk +8-16 h: hkkhhhhhmhjhhhhhhhh +11-14 l: lllqlllllllllcglf +12-14 w: wwdwwwwjwwwwtwwwwvw +3-4 g: ggvgg +7-9 q: qqqqqxqqqhfqsfqqbqvv +9-10 q: qqqqqqqqtqq +11-16 s: ssssssssssdssssjs +1-4 g: gggm +7-8 m: mmmmmmkmm +7-8 d: bxfdddsdp +7-8 d: ddddddwzdddddddddd +5-9 w: wwwwwfwwfwww +3-9 r: fqrchrrjwbrdsdtrr +13-18 z: zzzzzzjzzzzzzzzzztz +11-17 p: pskwgpmprpspvqpxp +4-12 z: zzzczzzzzzzzz +3-5 l: lltlnll +3-13 p: qvpnxrxprjdtpcspjck +7-9 m: wzmvxpfhbmjc +8-9 j: jjktkjjhjjjj +8-14 d: dddddtdddddddmdddd +5-6 b: bbjbcbbhbc +15-16 d: ddddddddddddddjd +12-13 t: tttttttttttts +2-4 r: rqrmr +6-13 g: ggtgggcgjzggtmgtgv +7-8 m: vmmmdmbmcbmm +9-10 f: ffffffffft +6-14 d: mqtfhdbrdsdljkrfnhw +3-12 b: lqbbcblbbxgbbt +2-7 z: nsbqqlzszzwtgqz +8-9 f: lmxqslffrd +1-4 f: ffflf +8-10 h: cqfsjlkdfhhp +6-7 k: kkkkkdk +16-19 n: nhnnvxnhjnnmnjnrnnkn +1-4 g: mggzgghgg +2-3 k: tcknkbkgcvl +8-11 q: bqqqqqqqtpq +12-18 w: wwwwwwwwwwwwwwwwwww +2-7 t: fljgtvt +2-3 w: dwmsltbqnw +7-11 g: szpgzxgggggsgr +8-17 p: pppppppvpcppppppmppp +1-7 p: pjpnbqk +1-6 z: zzzzzq +5-11 m: smmmzgmrjmm +6-7 s: rkkwvssqdhgxqx +5-6 r: rrrrrwrr +3-8 k: gkkjtfztsxrt +5-15 w: wsrrwwwddwwtwss +4-5 p: pppprp +13-15 z: xzjzzzfzzwzzpzdzzz +4-8 f: fqfhfbqfffvrfsfpf +16-17 g: gggggggghgggggghg +8-11 v: pchlvdfmvjrpsdsgw +5-6 r: rrrrwrdrfrk +6-8 f: nxmfjhkf +19-20 m: stmqmrddplzlwzdjbsmk +10-15 c: jccpcscccpccccxccccf +4-5 j: ksjjxjmvjwrjlqvxr +15-16 m: mmrmmmmmjmsmmmcm +9-11 l: lsrlfgxxcfs +4-5 r: lrprj +3-8 m: zdmmxmmjmmm +3-9 x: xxnxxxxxxxxxxx +6-10 q: vsqbjvpnnqqnhz +5-6 h: xghnhqmzf +5-6 c: rcgphkccb +5-6 w: wkdwjwwwp +5-7 v: vvvvsvv +1-6 c: ccccccccc +6-9 f: wfbfsfkftffffz +3-4 q: qqwqqqqqq +5-8 m: qmrmqkmgw +10-12 q: pqqqqqcqmlqnqqqjqq +2-11 x: bxxqrwvmpwwxkrx +6-8 f: fhlvlffn +4-7 w: wwwwwww +5-7 t: nbcbtpb +2-7 x: xdxxzgx +8-19 p: llgkthwqdpwcdcptlzp +12-15 x: xtxgxsftqgccldxc +2-3 l: xlklt +2-4 s: mwws +3-4 w: wwgw +6-7 m: mgmmmpm +8-9 f: mwzfmmkfw +4-11 s: ssssssssgsbssss +1-2 z: zzvxl +7-9 m: mmmmmmlmmmm +2-3 r: brxrt +3-5 v: hdrjvwv +3-7 f: bknpftfs +10-17 p: ppkpfpglfpgpzwvwxt +2-6 d: cddzdfdd +1-3 d: pdddd +13-16 c: cccdccccccccccch +9-10 x: khmxxwmqwxglf +1-3 q: qqqq +3-11 v: whvlvkrknmn +18-19 w: wwwwkwwwwwwwwwwwwshw +12-13 g: lgcqwrmggxmbg +8-13 x: xxxxxxxxnxxmk +3-8 m: mmmmmmmmm +7-17 d: dddddddddddddddddd +2-6 c: sccspkcccbz +1-4 b: bbnzb +3-4 m: mmmd +3-4 v: pmsv +4-7 t: qttttqd +8-11 b: bbbbbbbbbbkb +8-10 j: dlwsgtjdqv +5-7 x: fxxxxxj +4-6 p: ppppzlp +6-7 n: cnnnxgtnwnnnn +3-7 d: jdddjbpzddpd +4-19 x: xxxfzfxxxxqxxrxxxxmx +9-11 q: qqqqqqqqqqcq +14-16 r: rrrrrrrrrrrrdtnrrrr +8-10 k: kkkzkkkqkqkk +4-5 m: mmmmhm +12-14 b: bbbbbbbbbbbbbb +8-12 m: mmmmmmmmmmmzm +4-5 j: jjjfk +8-10 g: ggggggggggg +13-15 d: vdzdmdpxdnddxdn +6-7 m: pmzmmbnmmm +1-13 p: ppppppzpppppzpzp +2-4 z: qvfzfsscrthxtwpbkwsd +5-17 v: xtbdvdlrllvnphbcm +6-15 m: dbdmwmpnfmnhpmmb +1-9 p: ppppppppqpp +3-4 v: kvvqb +3-8 j: fxrcmjkxknlsn +5-7 w: wwvwkwt +6-12 v: hvmwwzrkjvhvjwlsjxv +3-4 d: dvzd +4-5 m: mmmmk +3-4 g: fghg +5-6 m: mmmmcmmmmmv +5-6 t: rlngtbbrscwf +5-15 w: wwwxwwwwwwxwwwqww +1-8 d: wddddddcdddtd +3-4 f: fffff +2-3 z: kkzzgzkc +9-10 z: zzbzzzzzzvvzvk +1-5 v: dvvgvvqvtsvvlsmj +8-9 g: ggggggggg +4-5 k: jkkkv +10-12 f: czbfffffffzwd +8-11 x: wshfbxnfxxxxxqpxxqqx +4-5 q: gmsqbsx +11-14 k: hkjkgkwkkkkfnp +2-4 c: gccccmccc +3-7 r: rrrrrrkrr +8-10 r: wrrmrzrrtrrrrr +4-10 s: stwnclhsss +1-9 l: lllgbxllr +2-4 v: dvvjgv +3-6 p: mrppkm +3-6 l: llnllll +9-10 v: dcvvmvvvvcvvvvvvl +1-4 d: dddzd +10-18 n: npnnsnlxmxvcnmgnqpns +4-5 l: llplh +4-5 x: mgxxzdcbqfglqrzshk +4-5 w: wswwzlwwwjw +3-12 w: wwwwpwwwwwwqw +3-5 g: xgggr +6-10 r: dlrjpncmsnq +5-18 t: ttttwtttttttttttttjt +4-5 f: bfdfr +3-4 p: pqvrlnp +6-11 d: knsrhrbcjndmgxhcphjr +3-6 x: xkkxxxx +4-12 t: thtjsrptttmmtpbbcctb +11-12 m: mxcmfbmfxmpmlm +15-20 c: cccpckwcbgscccccwccc +5-6 t: rrttgttttttrtnj +3-4 n: vnnn +2-3 x: xxzxxxxxxxxjxxxxxd +4-6 v: vvvvvj +11-16 q: dqqkqqqqqqqqkphvcgqq +13-15 j: jjhvjqjbjwwhjkj +6-7 q: dkrgqfq +5-6 j: gjjjcbj +7-9 n: nbqjklnnt +1-10 z: gzzzzzzzzzzzzzzzz +10-13 q: qddtjhrlsjkqq +4-5 q: zndqjhkznkfxkbdn +14-20 v: vfhvmkvvmvvlhssvvtvv +3-5 z: zzwzzz +16-19 s: sssssssshsssssslsss +2-4 k: fkks +1-8 t: ttttttttt +6-11 s: swvsvmjszskdjfp +3-4 b: nqrb +2-14 r: rcvrrvlcrrrnrrrkv +2-4 z: zjqznwzzpzz +1-7 h: phhhhhhhhhhhhhhhh +14-16 v: vvbvlvvgvvvvvvxrvvc +4-5 p: pppsp +4-7 b: rbdpbbplmqxbbb +1-5 b: pbbbbbbbbbb +1-5 d: dddddd +2-3 g: gqwg +12-13 d: dddrddqcldbpfc +3-13 n: chnthxplvnnvcxdwj +1-11 c: cnnctbgrvgflcccsc +10-12 n: nnnnnnngndnnnn +5-7 z: cjqpzzz +15-18 z: zjhzkzhkzzwzzqmslz +12-17 m: mmmmmmmmmmmgmmxmmmm +5-13 x: jxfxxxxsqtmkd +9-11 r: gsrrwrbrrrrjrmndrrrq +7-10 b: bbbbqbpbbqb +11-12 q: qqqqqqqqqqdq +1-9 h: hhhhhhhgvrhhh +14-17 l: lxlrfcnnlllllwvcllb +1-2 f: rppf +13-15 f: wfwrcwffffkfnnfffl +5-7 h: hhhhzhhhhhh +2-6 q: qqpdljq +4-12 k: kfwnkmkkkkkk +3-4 r: prqr +8-9 p: pppppppppp +16-17 c: cccctccccpccccctccwc +3-4 r: lqfrfkgtvrzb +2-4 g: gglv +3-5 z: zhzcz +3-4 p: ppgpp +6-8 q: qtmqqvkq +5-7 n: ksrnnnbsjls +2-9 z: zrlccsztzzzzzzh +1-8 s: sssssssss +3-10 z: zzvzzzzzzzqzzz +4-5 w: wwwzww +12-14 s: ssssssskssszstnsssss +1-9 k: kkkkkknpkkkkdkk +2-4 t: qnstqt +4-5 q: qqqbq +7-8 p: kkzpptpj +7-17 c: cccnqhckxhcxckmffbv +9-12 l: llpllcllllllzplhglz +6-9 j: jjjjjjjjrjj +6-8 l: lmllllln +4-10 d: dddldddkdd +13-18 m: sdkgmrdmmsxjcfmcwdwv +1-5 k: kkbkkk +8-9 b: bzbrbngbh +14-16 d: mdhdddpddddddkddgddj +5-6 p: zjmplf +3-4 x: xksxrx +1-11 w: wwwwwwwwwmxwzw +4-9 v: vvvdvvvvvpvv +3-5 x: bwxxq +3-5 k: ntkklsjkqvwvkxkqtkwr +2-4 c: gcjc +7-8 h: hppwshwhnbhk +10-18 n: nnnnnnnnnnnnnnnnnnn +8-13 w: qwwvfxwpwlwwwx +2-6 b: wdlmtbhkfnb +2-12 z: zzjqjkzblzzmfkzzz +8-12 s: svgsfssqssns +11-14 d: ddddddddddqddc +16-17 x: txxxrxzdxxxxxvhxxx +2-8 l: rllvllwxllkl +18-19 c: ccccccccccccccccccs +9-11 l: llllsllllrx +3-5 n: nnnln +5-6 k: frmkkz +2-4 l: tlmj +4-5 m: mmmvvm +15-17 k: kkkkmbkgkkkkkkkkmk +15-19 h: hhhhhhhhrhhhhhjhhhh +2-5 n: xnnjnd +7-9 k: kxkkkrxkvrkq +3-4 c: rccbm +9-10 d: ddldddrdkp +14-15 h: hlpcmhbvzhdhphr +4-5 m: mtmmvm +1-4 m: xmjmmm +3-18 m: qxmwmmbrdtxtqwcxfm +4-5 p: ppppl +6-9 s: ssssksssrs +7-11 q: qnqwxwppmqqqqwlk +3-5 w: wwwwww +13-15 v: vvvvvvvvvchvfvp +6-11 z: zdbzzqmkztzt +7-8 d: ndwmvdldx +3-7 h: hhjhqhhmpfzjvgmh +11-12 m: mmmcmmmcmhqf +7-8 x: xztkvxxd +2-6 h: wcnhzvh +4-5 x: xlgxpbxt +9-11 t: ktdtdxttgnm +3-10 j: jjjjjjjjjkjjjjjjqjj +11-14 x: xxxmxrxxxjxxcwxx +6-8 w: wcpwhfzwwcwj +1-6 n: wnfgxnnsvknngm +3-6 n: fkjnlnn +16-17 f: ffffffffffftffffx +3-4 v: vvzvv +11-12 r: rrrrrrrdrrrr +5-8 m: xwmmmmmmmmmmmmmmmmmm +4-7 x: nxxxkxx +7-8 t: ttttttxtt +7-8 d: ddddhddd +11-12 k: nqcbtrkvmwskm +1-2 d: dkdd +3-5 r: kbrrgxzkbr +1-4 d: ddddddfddddddddddddd +3-5 k: kkqkkkk +8-9 x: lrxkxhxxcxxxxd +3-8 s: rksdvzsss +7-9 k: kzhkkqmkm +6-11 h: hhhhhhhhzjhwcmnhhsh +3-5 x: fzptx +10-11 z: zzzzzzzzzhz +3-4 w: qmswdcdmxqwwqj +6-7 w: wwwwwnw +14-15 x: xxnxxxxxxxxxxxx +15-16 g: gkgpdftggvgchgsgl +2-7 k: vbvvfgkndklkk +2-3 c: qmccbcpzc +5-7 s: srssrssj +11-15 j: jjjjjjmwjjjhjjq +3-8 h: hktmzhhhchvhf +16-18 t: tttttttttttttttttrt +5-7 v: cvvknfvvv +1-4 c: xbgccfccqqvbgjtc +1-3 p: ppxppp +1-11 c: cgzddqwfkbc +2-4 t: xttht +14-16 w: pzvwgwwwwrhwlwwb +2-16 q: znqhqqqqzqpqqwqqqqq +16-17 w: wwwwwwwwwwwwwwwbwwvw +1-5 m: rmmmm +8-9 r: mfsdnqczrrqrdwvtcs +2-6 k: vktqrg +4-5 b: bbbrbbb +6-11 t: dxrnktlnbqtqt +12-13 j: jjjjjjjjjjjjj +15-16 l: lllqfllllllllllpll +13-15 j: jjjjjjjjjjjjbjz +18-19 z: fzwzxzzzkzmzzzzlpmn +2-11 n: nnnnnnnnnnpnn +11-14 n: mgnncnnnnncnnkn +1-4 n: rskn +3-4 g: xggg +3-5 d: lddgfg +1-5 s: thcss +1-12 s: cbzfbqstssqbss +4-7 z: jbfzzwnqhsgxxvndzlg +7-9 v: dbqzstvbcxgncgszp +6-9 b: gfklpbfkbbn +7-11 s: mslxkdsrtgss +3-5 x: dxxgd +8-10 n: npgnrbgnzr +3-4 j: mtzjrkmgfqmjbjhg +12-17 j: jjjjjjjjjjmvjjjjmj +5-6 j: srpckj +1-2 t: thtt +1-3 b: gbrl +19-20 p: phfppphpdptrxpwpzvcr +2-9 v: mvkwmtkhm +13-16 m: mmmmmmsmmmmmrtmm +5-11 f: ffffffffffffffffffff +2-8 h: hqhhhbhhhh +16-17 k: vjzqgvfqkrwtnldkcb +2-3 z: dzpptzzztzfg +6-7 c: brwcfcw +1-7 n: nnnnnnnnnnn +11-12 b: bbbbmbbbrwhbbbb +6-7 p: pppppgj +5-8 t: ttttwtttt +2-17 v: vfvvvvvvvvvvvvvvvvvv +9-14 p: ppbpdppppdpppplzqg +1-4 d: dddfdd +2-4 m: xbvmnmvmpsmfvpdzh +1-10 b: bbbbbbbbbxbbbbbbbbl +1-4 b: bgglftqqt +4-6 z: nzzfgzzzzzzkzzztf +2-3 r: pxrqdmrz +6-7 t: thttttrtt +7-14 d: ddddddkddddddjd +3-4 s: hsrsr +13-15 x: xwxxxjcxxxxxnxxxxs +8-12 x: xdmxqxxgxxxxzxxlx +6-14 w: wfwwwwjwwwwwwww +6-19 c: ldrqmvfpkrtrtqkcvtc +9-11 g: ggggggggdgg +3-6 h: hhhhhh +7-12 n: nznxxfdnnkrlnnfnnn +3-6 z: zgdzqztv +13-15 c: gcwsjjvnbnpkzncjlw +1-4 d: ddbg +5-15 t: tpntttttttttftrrtt +1-4 r: crrrr +7-9 d: rmddspmddz +3-4 w: wpbwzswqtwpwxmtpj +11-13 n: nnrnznjnncdnn +1-8 g: bggggggggg +11-12 b: hzltbtqgwxbbxb +1-3 b: hqbz +8-13 f: ffffffwfffffd +1-5 r: srrrj +2-5 f: fcffff +6-16 s: xmnhmbzlxvsmrffskl +2-3 t: tttgnxmtsdttttt +3-4 l: lplg +10-11 g: lggggggvggggggggw +6-11 v: vvvvvvvvvvwvvv +1-9 p: lppspptpp +6-10 p: zcpfqphgbppvcfmz +1-6 v: vvcvvzvvkv +5-8 g: ctggcsxg +3-12 s: sstsfjssssss +6-12 z: zzzzzzzzzzzzz +6-8 r: crrrrrcrrs +7-12 b: bbbbbbbbbgblbvb +2-5 f: qttqpfxmlf +4-14 d: dddddddddddddgd +15-16 k: wtchnbbwkmzsmrkk +1-4 n: nnnznnlnhnnwnznnnnn +5-13 f: ffrffffrtsndc +5-18 t: dmtwqmccltqrvkntft +1-2 f: fdnnslrfdv +2-6 r: txdtlrtbxrrxdsmrr +2-6 f: ljdgff +7-10 f: fddfffltfh +5-6 j: mjgjrgkjdj +3-8 j: mlbljhzn +5-6 r: slnrbjgr +10-13 c: lcxxccpcbvgdccgccccp +9-18 v: vvrnlvvvvvvsvvvsvvvv +6-7 k: nkkkkxk +3-4 q: rqqw +10-12 p: ppppppdkprppp +15-18 d: ddddddddddddddwddddd +16-17 n: nnnnnnnnnnnnnnnnlj +6-10 p: ktbfplppnp +1-7 v: xqpvxrm +5-6 l: sldflbxpdlltzlpjpml +4-13 t: tttvtttttttttt +15-19 x: xxxxxxxxxxxjxxxgxxdx +2-8 p: hhjdqvzmhxtkbbcptshb +14-15 g: gggggggggwgggdngg +9-11 j: jjjjjjjjwjjjjn +1-13 w: wwwcxxwwzrwwxww +3-12 l: vtxtlxjqrfplw +8-12 x: xqfdfzrxrnkwv +1-6 q: nqkqqqqq +5-9 l: lhlmklllllgjll +1-4 k: jwtkk +2-10 d: dvdjdddhdddddd +10-14 l: lllfslkltllqdrllxllv +8-11 r: rwplctrrrvpd +13-15 x: xdxxjddmcccmxxx +1-14 c: cccccjcjkcctcjc +9-13 m: gcpkqzgqwlznmqsmgxc +9-15 t: ttttttwtstttttwttttt +2-13 d: zkqdtclhmlpfd +14-18 j: jdjjjgjjjjjjjjcjjgj +9-13 h: hsgvzlktmzqhhw +5-6 b: bsbbbbbbbbbbd +3-4 z: zzsz +2-5 d: bcnrdgsfqnwqgdgmctq +9-12 q: qqqqqtcqqqqhzcvqfqr +1-3 w: rwww +2-8 h: tfhppjcrzchjhhrcnt +17-19 w: wwwwwwwwwwwwwwwwswww +2-7 f: fsffffffp +17-18 c: jcccfrzkgbzpmdwfvc +5-6 f: ffnfffvqff +1-2 b: bbtb +4-6 x: xgxxxgxr +6-9 v: crzvxfznvlx +13-15 k: nkkklkkvkkkkkxkkkkkk +3-5 m: mmzmwmmmm +1-6 b: brbqgk +5-13 k: qnmkktjgrkfqrzkkk +6-10 l: plllklfcllzvll +1-3 m: lmmmb +2-3 k: kqkk +4-6 k: kkkkkjkkkjkkkwk +2-3 w: nrwlrtkrkvtxwpr +9-10 b: kghdmcvswxbvtbjhdwb +9-11 n: fnnhdnnnnnj +9-12 b: bqbrbtbbsbbtgzgbb +6-14 f: fffffffffffffffffff +8-9 h: hhhhhhhhhhh +3-6 p: pwpfrbgfzqpghs +3-4 g: ggggg +7-13 c: bcccccpcccccccc +10-13 f: vppzffvnffkfq +1-4 f: vfffxfff +9-13 j: jjjjjjjjljjjjjj +3-4 f: ffhf +3-8 m: mmmmmkmcmmmmm +11-16 c: ccccccqccnsncccxkccc +3-8 w: wwwwwwwwww +3-10 c: llrkgsvwkcmphp +11-13 s: sssssspsssfsts +14-15 s: gssszgscsqfkssqsj +14-17 j: jjjjsjjjjjjrjjjjzp +1-9 q: wqqqqqqvqq +6-10 f: kffvfffdffsff +4-5 d: ddddbdddddd +10-14 d: wbdxrddtnrddddddg +6-9 x: xggxnfpcxxxdxxsd +14-17 p: pppppppppppjppppkp +1-8 m: tccmxmmm +6-12 p: vmspgmlzzqppfrpggglp +13-14 v: njnlcwlzdwwdvvgrfxtf +3-4 f: fmftfd +4-5 z: pvzzz +16-18 m: mmmmmmmmmmmmgmmxmz +1-4 z: pxzzz +9-10 b: bbbbbbbbbd +4-16 v: vvvwvvvvvvvvvvvrrv +13-16 f: jxlqrnngfghxfzfp +16-18 x: xxxxxxxxxxxmgxxxxhx +13-16 c: ccccccpccccctccc +8-11 c: ccccccccccvc +9-17 t: tttthtttttttttttzsl +7-14 w: wchwdrftbdhhww +3-6 r: kzrrzr +15-16 r: rrrrrrrlpzrvtrxw +6-9 t: tttttlttttttt +3-4 w: wwsww +6-8 c: cccccccxc +3-6 h: hphhhhvtxjrndzhh +12-16 j: jjvwsrkmjjqjdjjpsf +3-7 k: mtxqkzpkdkfkp +12-15 b: bbbbsbbbbzbbbbbb +4-6 h: qhhlshhhh +2-11 l: ljbllllljlllllzrljl +1-3 z: zzlz +1-3 w: wwnww +14-15 b: cbbbbbbbbpbjbbvgb +10-12 x: xdxxxxxxxdxz +17-20 n: nvnvzchcdfpnmnnsrnrn +1-5 b: bbnpxbb +5-6 b: gdkgsxqkbw +2-5 x: fxkgm +5-6 z: zzgzwzzxxn +2-4 d: hdqmdk +2-10 r: gnjqjctrrrvnjjvxgmx +6-7 v: cfdwvpxvvvpvvj +8-11 m: wtkprnmshmmmqtmzqq +3-5 j: jjwjv +7-11 t: xtfjvtttwtvttxtt +1-2 b: bbbb +8-10 f: ffffffqdfffffff +5-6 d: ddddmp +10-12 n: nnnnnnnnnmnnnnnnnnnn +9-10 x: xxxxxxxxkx +8-10 c: cccccccccb +19-20 w: wwwwwwwwwwwwwwwwwwmd +16-18 h: zhhhwnqnhhhhhghhvt +12-17 z: zzzzqzzzlzzzzzzzzk +2-6 h: hhvfjhrghhhhhthfhhhh +3-4 c: chgc +1-5 j: jjjjjjj +4-8 z: rzzzzzzszzb +9-10 t: ttttttttmt +3-5 g: bgggng +11-12 c: mcdcrcchsdccgtbj +2-9 f: rrjwgftffmnfm +12-15 r: rrgrrrrrrbrcrrrbrrrr +4-6 h: hxhxhghhhhhhhhhhhwh +10-11 n: nnjnznnnngnnqsnx +3-10 j: zfwklgrdnjtxj +3-4 b: bgrbbjf +3-4 n: nlqn +2-5 j: mslvj +14-20 c: cccccccccccccdcccccc +16-17 g: ggxtgggjcgggggggwggg +5-6 l: llvhfwhlwztxpdh +4-7 c: dcdzcccgm +10-15 q: qqqqqqqqqqqqqqjqqqqq +1-4 j: zdqw +9-19 q: hqqqqqqqjfqqqmnlbqqq +13-14 q: rqqklqfqqqbqhq +2-4 z: dlmz +10-17 g: xhnggglggqggqggqgz +6-11 j: djjjjjjjjjjjj +3-5 q: qqrqqq +3-9 n: xdlxngttnlmjb +7-9 b: bbbbbbzbtb +1-2 b: jbbtb +10-18 z: qzzzztzbzzzzzkzzzzz +3-4 p: pjjwpw +8-10 q: qqxqqqtqqpnm +4-7 f: fffffdff +1-10 j: pjjjjcjxjbjjj +3-11 c: tfrjqdtkcjcjkcwn +7-8 p: cpptjkpf +9-10 g: pggggggggvg +1-5 b: lbjbbbzbb +2-4 m: mmmtmmm +8-12 w: hwpkjdwzpwwwkcsw +6-10 b: mbkskbpbkr +13-16 q: qqqcqqqpqqqqqlqjqq +6-12 r: rlxrrrlrgjkr +15-16 k: kbkkkkfksmkqgkrk +1-2 l: lwll +3-5 x: xqxlcb +7-8 s: sssssssp +5-8 m: mmmmmmmrmm +2-4 l: lnllllzlsl +4-5 z: zzzwzzzq +5-8 l: hqdflnll +1-2 v: jvvzczgrv +9-13 z: zhzzzdzzzzzzzqzp +4-5 d: dddcdddddd +8-9 s: ssssgsshss +1-2 c: cccc +2-17 h: hhhhhhhhhhnhhhhhrhh +7-9 n: ndnlnnnnnz +10-14 p: hppzpxprfvrpppphpp +14-15 b: xwvqdfqmpbzvbgbtt +7-8 q: qqqqqqqn +11-15 m: mfmmmfmmmmmbmmn +2-4 g: bgbpr +5-10 f: fnbbpmffjphv +6-7 h: nnshthh +4-10 c: cccwccccccccc +17-18 p: hppnmppmpppppwphpc +7-8 g: ggggmggdg +1-3 f: fdwjpkdrbfff +5-10 v: lmvcldnwwzjznzsctzvv +10-14 b: bbbbbbbbxbbbbbbbb +4-9 r: whkjzsvrr +9-18 h: hrdzhrhrxdnrhfhhhh +2-5 n: nnvqbnbhwqfr +1-11 q: qndbrqxtkqq +6-8 r: rrrjsrlrrg +12-16 z: jhzzzzzzzzzzzzzwz +4-6 q: wstfcqqsbqq +1-3 g: bggg +5-11 w: xrgvsjvwjrd +13-16 b: bbjbbbbbbblbpbbbbb +7-8 h: hbhdqphmp +15-19 d: dvddddddddddddmdddl +7-13 p: vtbclnppvvqxljk +7-9 k: xkmksddkg +11-13 z: zzzzqtzzzqmzpzz +12-18 x: xxxqxxxxxxxxxxxxxt +5-6 f: fffffc +17-18 v: vvvvvvwvvvvvvvvvvv +4-14 r: ndqxfrbtfmptcrf +1-2 z: mszzz +5-9 n: nnnnnnnnnnn +1-3 n: ftfdl +14-19 n: tnjgfppdhswwdhclxmn +12-14 l: lllvlllglllfll +7-16 p: ppppppppmpppppppppp +6-17 c: sccccqxwscvbmcccxcz +1-6 x: wxxxxxxx +1-10 v: kdkkkmvgvmsfswvbtsc +16-19 k: kkkkkkkkkkkkkkkkkkdk +7-9 c: ccccchcjd +3-10 v: vmpvvmgjkfsv +10-18 s: ssssslsssqnjssssss +8-11 h: htvqnhgbszh +2-14 j: ptdrlpnnjrpppjrgp +8-10 w: wgxwwtntwrsczwwrjz +4-6 b: bbbqbbbbbb +2-3 x: gxxx +6-20 t: fntbvdtjmtsktztpdgkt +2-4 f: fffbff +7-14 m: mmmmmlgmmmmmmwlmmmm +17-18 z: zknzsdlzzszzzzzxzz +18-19 c: cccccccccccccccccvc +4-7 v: bwgvvxvvv +1-8 k: kkkkkxkdkkk +1-2 x: xfsxxd +4-6 r: hhxhrrlrbwwnjkkwb +1-7 r: rnxrrrrrrrrlrrr +9-12 l: lllllwllzlll +3-9 l: llllllllll +12-19 c: cccccccdtccrcclcccc +8-9 t: tttttttttt +2-3 n: nnkn +3-5 l: xqvqlsjlgl +4-5 k: kkkrrkn +5-7 d: mdrdmddpmd +4-6 c: ccccch +3-5 m: mmfmcmm +6-8 x: gxxdzbxzxxxx +2-3 r: rmtkgcrvlrg +6-7 r: cmrrwrzv +2-3 c: dcjlzl +6-13 b: bbbbbbrpbmbmnbbb +1-5 s: ssssws +2-8 l: sllwlvjl +3-5 b: bbxlbbb +1-3 c: cczpq +10-14 k: vqgnlzbbkjkljk +3-7 h: hhfhhhhhhhhhhhh +5-6 k: kfkkrx +6-7 q: qqqqqqr +5-8 l: dsqllgzl +8-9 r: rrrrrrrrxr +3-4 v: mvvh +1-4 p: ppppppp +17-18 x: xxxxxxxxxxxxxxxxkxx +5-8 b: bbbbcbbpb +7-10 j: jjjjcpjjjwjjjjjjjj +1-10 r: rscprvknxrgxqzsrs +3-7 w: wwgwwwhcwwwwwww +1-3 b: blkb +4-5 r: zrrrhlt +3-4 m: wcmmmfh +3-5 t: mctnxtktrsj +1-4 c: wcccc +4-13 j: sjjjjjjjjjjjtjj +7-8 r: fztxkwhrrxnnn +5-6 r: rrqrrrr +1-5 q: qqqqvqqq +8-14 t: ttvpttkptthtttrcj +2-7 n: znjqsvpstfjph +6-7 l: llllllnl +19-20 c: vwltcctcmcdccrqdccwc +4-15 d: bfkxfrsznfkdzpjmbp +12-15 q: qqqqqqqqqqqvqqqq +6-10 t: tttttbttktt +1-18 c: ccdczcvccvclcccvkccb \ No newline at end of file diff --git a/2020/2/main.cpp b/2020/2/main.cpp new file mode 100644 index 0000000..a112f70 --- /dev/null +++ b/2020/2/main.cpp @@ -0,0 +1,72 @@ +#include +#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])