From 530e53c22c56ea234905dbad3b09406a609ed36b Mon Sep 17 00:00:00 2001 From: Gnarwhal Date: Fri, 11 Dec 2020 09:24:22 -0800 Subject: [PATCH] Restructured project and updated day 3 --- 2020/Makefile | 16 +- 2020/day1.input | 200 ---- 2020/day2.input | 1000 ------------------ 2020/{ => days}/day1.cpp | 19 +- 2020/{ => days}/day10.cpp | 13 +- 2020/{ => days}/day11.cpp | 13 +- 2020/{ => days}/day2.cpp | 13 +- 2020/{ => days}/day3.cpp | 57 +- 2020/{ => days}/day4.cpp | 12 +- 2020/{ => days}/day5.cpp | 13 +- 2020/{ => days}/day6.cpp | 12 +- 2020/{ => days}/day7.cpp | 13 +- 2020/{ => days}/day8.cpp | 13 +- 2020/{ => days}/day9.cpp | 13 +- 2020/{ => inputs}/day10.input | 0 2020/{ => inputs}/day11.input | 0 2020/{ => inputs}/day3.input | 0 2020/{ => inputs}/day4.input | 0 2020/{ => inputs}/day5.input | 0 2020/{ => inputs}/day6.input | 0 2020/{ => inputs}/day7.input | 0 2020/{ => inputs}/day8.input | 0 2020/{ => inputs}/day9.input | 0 2020/{template.cpp => misc/day.cpp.template} | 9 +- 2020/misc/main.cpp | 36 + 2020/misc/main_test.cpp | 66 ++ 2020/misc/print.hpp | 31 + 2020/{ => misc}/types.cpp | 0 2020/{ => misc}/types.hpp | 0 29 files changed, 245 insertions(+), 1304 deletions(-) delete mode 100644 2020/day1.input delete mode 100644 2020/day2.input rename 2020/{ => days}/day1.cpp (87%) rename 2020/{ => days}/day10.cpp (91%) rename 2020/{ => days}/day11.cpp (94%) rename 2020/{ => days}/day2.cpp (91%) rename 2020/{ => days}/day3.cpp (60%) rename 2020/{ => days}/day4.cpp (95%) rename 2020/{ => days}/day5.cpp (90%) rename 2020/{ => days}/day6.cpp (91%) rename 2020/{ => days}/day7.cpp (93%) rename 2020/{ => days}/day8.cpp (94%) rename 2020/{ => days}/day9.cpp (92%) rename 2020/{ => inputs}/day10.input (100%) rename 2020/{ => inputs}/day11.input (100%) rename 2020/{ => inputs}/day3.input (100%) rename 2020/{ => inputs}/day4.input (100%) rename 2020/{ => inputs}/day5.input (100%) rename 2020/{ => inputs}/day6.input (100%) rename 2020/{ => inputs}/day7.input (100%) rename 2020/{ => inputs}/day8.input (100%) rename 2020/{ => inputs}/day9.input (100%) rename 2020/{template.cpp => misc/day.cpp.template} (91%) create mode 100644 2020/misc/main.cpp create mode 100644 2020/misc/main_test.cpp create mode 100644 2020/misc/print.hpp rename 2020/{ => misc}/types.cpp (100%) rename 2020/{ => misc}/types.hpp (100%) diff --git a/2020/Makefile b/2020/Makefile index ede9575..812ac33 100644 --- a/2020/Makefile +++ b/2020/Makefile @@ -1,12 +1,16 @@ -day%.out: out/types.o day%.cpp - g++-10 -std=c++2a $(flags) $(@:out=cpp) out/types.o -o $@ +day%.out: out/types.o misc/main.cpp days/day%.cpp + g++-10 -std=c++2a $(flags) -Dcurrent_day=$(@:.out=) days/$(@:out=cpp) misc/main.cpp out/types.o -o $@ -day%.cpp: - cp template.cpp $@ +day%_test.out: out/types.o misc/main_test.cpp days/day%.cpp + g++-10 -std=c++2a $(flags) -DTEST_BUILD -Dcurrent_day=$(@:_test.out=) days/$(@:_test.out=.cpp) misc/main_test.cpp out/types.o -o $@ -out/types.o: types.hpp types.cpp +days/day%.cpp: + cp 'misc/day.cpp.template' $@ + sed -i -e "s/current_day/$(shell basename $@ | cut -f 1 -d '.')/g" $@ + +out/types.o: misc/types.hpp misc/types.cpp mkdir -p out/ - g++-10 -std=c++2a $(flags) -c types.cpp -o $@ + g++-10 -std=c++2a $(flags) -c misc/types.cpp -o $@ .PHONY: clean clean: diff --git a/2020/day1.input b/2020/day1.input deleted file mode 100644 index 3bea509..0000000 --- a/2020/day1.input +++ /dev/null @@ -1,200 +0,0 @@ -1587 -1407 -1717 -1596 -1566 -1752 -1925 -1847 -1716 -1726 -1611 -1628 -1853 -1864 -1831 -1942 -1634 -1964 -1603 -1676 -1256 -1906 -1655 -1790 -1666 -1470 -1540 -1544 -1100 -1447 -1384 -1464 -1651 -1572 -907 -1653 -1265 -1510 -1639 -1818 -376 -1378 -1132 -1750 -1491 -1788 -1882 -1779 -1640 -1586 -1525 -1458 -1994 -1782 -1412 -1033 -1416 -1813 -1520 -1968 -715 -1396 -1745 -1506 -1024 -1798 -1870 -1615 -1957 -1718 -1349 -1983 -1387 -1738 -1588 -1321 -1160 -1907 -1861 -1940 -1475 -2004 -1852 -1760 -1608 -1028 -1820 -1495 -1811 -1737 -1417 -1316 -1087 -1803 -1595 -1346 -1971 -1692 -1678 -1330 -1480 -1097 -1898 -1973 -1567 -1733 -1336 -1381 -1327 -1670 -1436 -1989 -1334 -89 -1862 -1715 -1743 -1967 -1765 -1402 -1729 -1749 -1671 -1196 -1650 -1089 -1814 -1783 -1225 -1823 -1746 -2009 -1886 -1748 -1481 -1739 -1912 -1663 -1668 -1314 -1594 -705 -1449 -1731 -1487 -1648 -1466 -1317 -1979 -1799 -1926 -1703 -1656 -1978 -2005 -1865 -1982 -1951 -1892 -1713 -1744 -1598 -1606 -1583 -1895 -1804 -1430 -1816 -1364 -1575 -1918 -1431 -1812 -1471 -1797 -928 -1934 -1156 -94 -1563 -1909 -1453 -1392 -1427 -1819 -1524 -1695 -1866 -2008 -1413 -1698 -1051 -1707 -1904 -1681 -1541 -1621 -1421 -1809 -1576 diff --git a/2020/day2.input b/2020/day2.input deleted file mode 100644 index d1612d4..0000000 --- a/2020/day2.input +++ /dev/null @@ -1,1000 +0,0 @@ -9-11 p: pppppppppxblp -2-4 b: bbxbb -3-5 q: dqfqb -5-8 g: ggcgggglg -10-18 l: gllpmlgtrmnllhllrlll -18-19 z: zzzzznszzzzzzzzzzzxz -3-6 r: frrhxsnrmgmw -1-8 n: zkxhnxnzghnm -11-12 z: zzczzzztlzlzzzz -4-7 q: qqqbncqqq -3-4 c: ccvfc -19-20 l: sltlklljdlzglwllllzl -6-16 h: dhhhrhvhnhdchfsnhq -3-7 l: fllllqjlll -8-9 k: xkkjqklkm -1-2 l: llgpl -2-4 x: qkjxvqlv -5-6 c: cwcccjch -3-7 n: bnnhnwnqtdnndnncnd -8-9 n: nnrkmdnkn -6-9 t: ttttrtltptgvcd -3-4 h: hhwhhhdhhhh -7-8 w: wdwvcwwszcwwwwwq -2-4 n: vnng -3-13 v: vvvvvvvvvvvvjv -9-11 c: zcccccccccfcbccc -10-11 w: wkwwwwwwwxw -10-12 z: zzzzzjzzzrnzz -5-6 t: ttttts -13-19 b: bbmfbbbbbrbbgbbbrbbb -8-9 d: bdddvkddjbdgdd -19-20 m: mmmmmmmmmcmmmmmmmmmq -6-18 w: wwwwwwhwjwwwwwwcwjw -4-10 t: tttttttttj -2-7 j: fbdgmfjbjgjn -7-8 w: wwwwwwcww -8-12 c: cbmdccbccckjccch -13-15 f: fpfffffffffffqf -7-11 t: sbtstwdxjpclwd -1-3 s: shkkqcs -7-8 l: bdggzczl -1-6 g: zgggggglggggggw -12-16 h: hhhhhhhhhhhhhhphhhh -8-19 k: htknkhkrkdkhkpwppkk -8-10 k: kkxkkkbrkgk -8-9 h: hvhhhhhfhhv -15-16 x: xxxxxxxxxxxxxxxh -1-12 b: bgwpjbkhbptsbbb -9-10 j: pjtjpjpnbjjlsgbn -8-9 s: sscplbswssssglxs -14-15 j: jjjhjjjjjjxjjjj -1-4 q: qnqj -3-5 d: qpdddqvwbzldf -14-15 b: bbbbbbbbbbbbbbt -1-2 t: tdxt -1-7 g: dlpkvrgjzpnr -3-11 m: lmnwjjxpfmm -3-8 l: llglllllll -2-4 r: gfmrlbmsvqzrmbnd -5-9 s: srsqssssds -8-9 v: vvvvmvvvhw -7-10 d: mddwdvjdcdwdcgddd -4-7 k: fksjkkkk -6-9 t: fnrxmlwtt -11-12 d: dddddddddfmd -4-5 z: zzdzzzz -11-13 z: zzzzzzzzzzpzmzzz -12-14 z: zrgnvcrxkzzzrb -10-13 q: qpqqqqqrqxvqq -6-10 g: gglggggggzgggg -2-8 j: jfqjrdjjjjjj -7-8 z: hzlvrczjp -4-5 k: kggjkl -4-7 m: mpmmmcmm -13-14 x: xxxxxxzxxxxxxw -6-7 n: znnnnnlpjcn -10-16 g: gggzvgggntggfgghggg -2-17 n: hnchrpvzhkdsnhgcnfql -2-8 f: fkfpffff -4-7 s: qwdspspj -6-7 r: rrrrrnx -7-8 p: wpppppsp -8-10 m: mmmwmjmmmvmzpm -6-7 j: jjjjjncd -3-4 k: kxkk -2-4 z: czzmzz -11-12 t: tttttttttttzkp -10-17 t: ttttvtltdttrqtztr -3-6 n: nnnnvvxv -7-8 v: rvvpvvvpsvv -1-2 r: nkfgnr -4-11 c: cccbccclcccc -7-12 q: qpbqtqkqqqqqqq -2-7 m: mfmmmmmmxmnm -10-11 n: bnnnpnnncxrnnnn -10-14 n: nsnnnnnwljnsnnn -5-9 b: vcvcblrxbvjbtzbrmbr -3-9 m: kmmmmxmmkmmk -2-10 l: llbllgzllnlll -5-6 d: ddpdwdddxhpdqd -12-18 j: cjfbjccqgxlczjptqlk -1-3 z: mzzz -5-11 m: mdfmmmmtmgw -2-14 h: nhhnbhghhlhhchsqsr -3-4 t: jvtt -2-8 t: tttkxxtsttht -7-15 w: wwwwfwwwwwwrbww -1-4 j: rbjj -8-12 f: ffkhffffcsfzff -10-12 p: pppcgpqphprh -10-11 l: lllllllllsl -7-8 s: svsssssss -4-5 c: cvjcc -1-5 v: vcdcd -5-14 z: zzwkzztzzzzzbzzvzzz -11-12 s: sssssssssssps -5-7 b: spmtbpn -5-6 c: cccccf -10-12 p: ptpppppppppk -4-13 f: ffkffffkffflb -2-5 t: nttqftpnwbjbxmqdqv -17-18 w: wwwwtwwwwwwwwwwwkwww -7-9 f: lmrffdbffvfmf -2-5 h: hhhvzrhh -10-11 q: qmdrdfqgzql -3-11 g: ggggggggggm -4-5 z: zzzrzzp -5-7 w: wwwwkwwww -10-11 f: ffffffffffp -6-9 v: vvvvvvvmv -4-5 x: wjxxxxxtd -12-13 p: vppppppppppzbp -2-7 b: bqntbls -15-16 p: ppppppppppppzpfxn -2-3 b: bbcnbq -10-11 k: kkkklkmkkhk -4-6 w: wwwdjb -4-6 b: sczlwbnffbnxbvjbmj -3-17 m: jmmlmmmgmmmjmmmmmlmm -6-18 z: zmkwvzkpqzmzdfgdvt -5-6 q: sqwqqq -1-3 g: gjgt -5-8 x: bxcxxzxxws -4-5 c: rnscvcngbcmpddkcvctk -7-11 g: ggggglvgggngg -2-11 l: lsqlzlllllklgfl -2-9 m: cmqkbmdxp -6-7 w: wwwwwww -8-13 q: qbqzqqqqqlqqw -3-4 n: sfqnnnwvzn -1-2 w: nwww -2-4 v: hvvbqgnfl -14-15 m: gjgdmmmmkmqqcxmrsm -2-3 z: zzzx -5-13 q: qqqqdqqqqqtqjqq -4-5 z: zzzzk -5-6 t: tttttf -3-6 z: ztwzczkz -3-5 l: llpljllllllll -2-3 s: ssscp -8-10 d: dddddddwdddddwddg -2-6 s: sbssps -1-5 f: ffbfvfxbkmbhvbcfmxpf -1-6 j: gqfrmjgsgjjhcjhn -2-5 l: lwvllll -2-5 z: zkzhzb -10-11 s: wsblfxvmvsslbhfjtsws -11-17 f: fffffffxfffffffftfff -4-5 r: rrrkbrr -7-10 w: qwqwwwgzrdxww -6-8 s: ssssssscs -4-6 q: qbqwqzfqcfgkmzqxb -6-10 t: ttncfqqtttttp -2-4 m: bbzcjjqmfvln -4-7 n: cnqhntshdnnrnrnz -7-12 d: vmdndkzpmcbd -6-7 p: tpqpppzpjp -3-10 r: rgrrrpzrbrrr -2-15 h: ghbfhbgrtxrshphhl -2-6 j: pjjjjlj -6-9 j: rjrjjjwfjn -10-13 s: sssssssssjsssssss -1-6 c: crnjccgnw -6-7 l: qrllgql -12-13 z: wzzzzzzzzzzfz -1-2 c: ccclc -2-6 f: qdlflfr -4-10 r: drrrrrwrfrr -5-6 f: ffzffnf -4-6 p: hkppkbppp -8-9 r: rrrrrrrrx -4-12 f: fffffffffffwqp -4-6 q: qtqtjq -4-5 w: wwwcw -2-3 r: qrrr -7-10 k: nkpgzskkrb -6-9 h: hmsshhhwhhhhh -2-18 d: kxqddddqddsmddcdddwd -6-7 s: sssssssss -4-8 h: hhhbthhhhh -1-8 d: dtsbqtrpwdgfdzrtf -6-7 b: bbbbbwp -5-6 p: ppnpqjp -4-13 l: rtqpmllslrlxcblldqtc -3-4 m: wmmkcm -4-16 b: qkbvbvgxtlqbgmwc -4-5 h: hhhlghh -10-11 f: fjfffffffgjff -9-12 w: gwnfvwwrwswnqrvg -4-8 k: pjkkfkbqqzkmfk -2-8 x: xwxxxxxcxxx -11-19 w: wwwwwdjwwwrrwwlvwwww -4-14 w: rwqhwqwwlhpwfwwpww -7-9 j: vjjjjqdjjjjjj -15-17 x: kxrmxjvxxxvxxxzxxxf -3-10 p: pwpxppzgdrrx -1-5 p: ppppp -10-19 n: vfnwnjstnnjnqnngnzs -2-5 m: phsmq -5-6 m: mmmmxmm -2-12 f: tftgcmcblzcljsdlbvf -6-11 b: hbbbbbbbzhwbtbbhmrb -7-11 j: jjjjjjvjjjq -3-4 d: dddgddnmd -11-14 f: fxfffffftqfflffffpf -14-16 x: xxxxxcxxxxjgxxvt -6-7 h: hhhhhht -7-8 h: hhhhhhzphhhh -5-12 w: wfwwwjzwmpxwmw -2-7 h: chcjhhqhdlfshxvhz -7-15 h: hjhhjvhhhhqmhdhjh -1-2 f: bvhf -4-6 k: rkctkkm -5-6 n: nnnnnn -10-11 j: jjjjjjjcjjs -4-7 b: bbgbnkp -2-5 d: dddddjvddxdk -11-19 z: svzzgzzmzznzzzkcdzzz -8-9 z: zzzzzgzmz -4-10 v: vsvvvvnvsr -5-15 v: mvqvvkjfvwdvvdl -13-14 s: ssssssqzszssmk -3-4 w: wbwg -10-11 d: kdbdcddqddxdddd -8-9 t: tttttttntt -2-10 m: mqmmmmmmmm -3-8 c: bcswcncchpxcxcrccrx -4-10 q: qqqplwsfxgq -15-16 h: hhqhhhhhhvhhhhhthhhh -11-13 s: sssxssswsswsr -6-7 z: zzzzhvzz -3-4 j: ktjdxsjjxjtnq -5-7 w: wwxwlwwr -2-5 l: llltll -2-6 m: qmgvtmtp -11-16 v: vvvgvvlvhvvvvvvvvvgv -2-4 j: jsnjf -11-12 g: gdlcvdgzgqpg -10-12 x: rxxcxxxxxrrxx -9-12 n: nnnnnnnncdnn -6-10 j: vjjjpjhjjs -5-6 d: dcdddt -3-13 c: cccccvctcbvcvpcccc -1-7 d: ndddzzdx -9-10 w: wwwcwwwwfr -9-18 q: xjhsjqqrqpgprjmqqq -8-11 b: bprbbbwkbbbb -4-14 w: wxcwzsswmsqvfjvjzj -5-6 b: wbbmzbbm -8-13 f: lpjfsfswfffgfkff -1-3 x: vxxx -6-7 x: btxxxxcx -6-8 r: mwqrrqrrxr -7-14 h: hhhhjllhrsxtrhmbbpwh -7-10 f: phqzgfwfrpffpzq -6-17 d: ddddddddddddxdbdgdd -5-11 f: fhfnfflfhjvwvfff -11-12 h: hhgbtnkhhhhh -2-4 f: fdfgffr -5-6 w: wwwwxw -4-9 z: zbzzzczzv -2-4 k: jfpkc -3-4 r: kwgr -4-5 k: kkkks -5-6 r: rrrdrsr -5-6 t: tpwnmttclcrtt -18-19 t: ttbwxtxgfsphgtzzplbt -1-5 w: tthwwvw -10-13 z: mzzzzzwzzzzztz -7-10 r: rzrjrfpdrrrcmmrr -2-4 w: wwww -5-9 m: vksmmzdpsm -1-2 q: qqqqqqq -1-6 c: pccccn -3-8 r: pbchhhrr -3-8 v: bfdvkvdvglvn -3-6 h: hhhxhshhl -4-7 m: mkwpkwmtmm -10-11 g: ggggmggggcg -1-6 j: jjjjjw -4-10 z: zvzzxzzgzzz -7-9 k: kkkkkkkkjkkkk -4-18 f: vlnfpdzvbqhvsfmhqtf -8-11 s: sssssksshsssmhs -2-6 b: bbbbbm -2-3 h: hhvrlcf -10-19 c: mccwczqbjdlgfccnrqc -8-12 x: rxxxnxtfxcxxxpx -13-14 r: rrrnrrrrrrrrmrr -4-11 h: mhzstqhhghhhbhhh -10-11 f: fffffffffpf -7-8 j: jjjjjjmv -5-6 f: fhfffv -3-4 z: zzxtzq -5-6 v: jvszvzvvg -9-13 v: wvvgvdvvvsrjcg -10-11 t: pcttrntttttdthtxst -1-5 v: vvvvpv -6-9 q: qfqqqlqqqqq -4-8 f: ffffffmfkkfzpffffvff -3-5 n: lnmnnnnnnnn -1-5 k: kkwmdkflxtqktmcxdl -1-3 z: tnqp -15-16 h: hhhnhhhhfhhhhhjhhh -2-6 m: mmmxmb -7-12 q: qqjqhqfqwqcqqkqmql -6-10 s: ssjvrvsgsshsss -11-15 n: nnnnnnnnnnrnnnj -14-15 x: xxxxvxxxxxkxxxzx -9-14 b: bbbbbbpbbqbblbbbb -4-12 h: knthjdhlrxtpjwhnhn -8-9 v: vvvvvvvjjvvvv -2-3 d: dktdvd -6-8 z: zzzzzzzx -10-13 t: jrjfklzstpxwt -4-16 n: mngnnqnbnnwnqrdgk -3-5 v: vhqvvn -1-4 t: jhtq -8-11 f: qfffffqfffff -14-15 x: xxxxxxxxxxxxxxx -2-12 s: scsstsssmcssswgsw -8-13 t: tttttttqttttt -8-10 d: ddddddvdfbq -9-15 d: sdqpqddddjrdjnj -17-19 c: cccccdldcccpbccxgcc -6-14 v: lvvvvsvvvvvvvp -16-18 p: ppppppppppvpppppppt -1-3 v: vkvtzlvrdcvzplznltqs -8-10 s: sssssssssns -1-3 w: wcwfwxnwwp -8-10 v: kvvvvvvvvvkvvv -7-11 s: shsssssssns -9-10 w: wwwwtwwgkwww -1-2 x: vxxn -4-9 g: lkgggrcgpg -1-5 n: fjrnn -4-6 x: xtxzxxx -18-19 z: zzzzhvzhzzzzzzzzzsz -15-18 p: ppppppppppppppsppppp -11-14 h: rdhhhhhhhghhhrh -3-9 v: vvvvvvvvqvv -4-8 p: bbpmjpplp -1-15 n: qndxnnsmnrnsnnnnn -7-9 c: cccccctccc -2-6 m: xwfnmmn -4-16 t: nbttltzvhqjtcgbtttkt -7-8 r: rrlrrrrsrbr -3-5 h: hhghh -3-4 m: mmmxm -15-16 k: fckzkjskrkkkdkkl -5-6 c: cbsxmh -1-6 x: fxxxxxx -5-12 d: wdddqrdkwkmdfwd -3-10 s: smsqncrsjjdmjdlsls -6-7 k: vkkskkjkwkrkkk -9-17 z: qwzhqgrnvzzbzlhjz -5-6 w: dwwwwp -5-8 n: ncvgqnvn -5-6 v: vvnvvwvv -3-4 x: dxxxsbsxx -8-12 t: ttgtshxfmzlc -10-17 x: xthkjfxlktkbhdxzx -5-8 q: qqtqqqkqq -4-10 d: ndddgxvzswlsgdpnrc -8-11 h: bgcfhhrkhhb -16-19 g: qgdmbghrjhgcvgwpggg -3-5 s: fbsqqszkdkqzw -9-10 h: hhhhhhhhdhhh -15-17 b: bbbbbbbbbtbbbbzbbb -11-14 q: qqqhqqqqqqqqqsq -4-18 r: rhhrrpghwbqfznflrrr -14-15 l: lllllllllllllrl -8-14 s: nsfpsrsssnffssjss -17-18 k: kkkkkkkkkkklkkkkck -1-12 c: cmnccccccccktcc -7-14 p: pppppphppppppp -1-2 j: jtjq -2-6 w: wwpxxrwwwdwwh -5-12 p: zspwppnppdghqplnj -3-5 h: zhqphfth -1-3 q: xqqq -4-9 r: qrzrfgpnbj -7-8 q: qqqjqqqcqw -4-6 m: mmmmmwdmm -4-6 s: sqcssgnsrrddgshvbcs -2-6 m: mmsgtr -3-9 v: wvwvvvmvv -3-5 j: jcjvtgjjjxvjjgjbhj -4-6 f: qsffzgff -8-9 x: nxxbxwfrxx -1-7 m: mvmmmbmmljmg -5-8 d: pdcdqdddwdl -1-3 m: mmgns -19-20 r: rrrrrrrrrrrrrrrrrrxr -1-4 h: hpghbhkhhr -5-9 x: xxxxtxxxxxxxxxxx -19-20 p: qvwdwnssfckjczggpghp -8-12 k: kkkkkkkfkkkkkkkk -10-12 b: cbbbbdbbbqbkbb -2-8 n: nkkpnprnfcnnwsmndqnn -11-12 d: ddddddvddddvd -4-8 j: jjjjjjjqjjl -1-3 l: lvdlslllhllsg -12-15 j: jzjjjjjkjpjjjjqf -6-9 s: sssssssssssss -1-2 z: xzzcnjrzzzzzzz -5-6 h: hhhhhh -7-13 x: xxzxvsmxlbxpxz -2-4 d: dpnddbdfdm -9-16 n: nnnnnnnnknnnnnnr -4-5 n: nnnvnn -13-16 p: vppppppppppppppz -3-6 w: wwtwww -7-9 n: nnxnwntnnn -4-12 q: mqcnsrvqqzgqkwz -3-4 t: dwtj -9-12 r: rrrrwrrrrdrcr -8-9 w: wwtcwwjhwwww -6-8 w: wwwwwwbgw -5-15 f: pgflfgfbbvvffkfkmw -10-17 s: ssssssssshsssfsssss -19-20 m: mmbmxfmmbzqhmxmxmmmw -11-12 d: ddddddddddsd -13-14 f: fffffffffffffdf -1-6 n: nnnnnnnn -11-19 x: wmxxbxxkxxxpxxxxxxc -2-3 z: szgkqvmzwztdcxtvn -16-20 z: zpzhwdtdzhvgcpdpzzzz -15-19 p: ppmpcxppppprsgnpppg -4-5 x: rrxfxxxqx -1-2 q: rqdwn -4-6 x: pkfxqxxfxbk -13-17 c: ccccccccccccncclc -5-7 z: zzzzvhz -5-6 r: rrrnrl -2-5 g: mfgkgxhckg -3-6 c: cnmcjcccdccccv -7-11 t: dttttttrttxtt -6-9 p: ptlfppppcvsp -3-5 g: ggxkwtj -5-16 x: phzxlbhqxgxzwjwkkxp -7-8 s: wsssssmsn -1-7 m: pmgrmkmmnnm -15-16 n: nnnnnnnnnvnnnnnln -6-8 t: ttzttftst -5-7 g: ggggggggggg -13-16 d: ddddddddddddpddbdfdd -13-14 f: jclffflwlffbfvffffbn -3-4 j: xjzjjjr -8-14 n: nnnwknndnlnlnn -6-7 s: sxsssnzs -6-7 r: rrsprrjrcrb -10-11 w: qwwcwqzwrbq -7-10 b: bbbbbbzbbbb -5-6 d: ddddkd -16-17 d: ldldddddpdldldddd -5-14 w: zdtwxnxwhwwpww -6-9 q: mqqxqsqqq -2-11 g: gpggzvgggkgmcmt -6-14 k: kfkkkxkkkkkkkjkk -2-3 m: zfmm -13-17 k: kkbkkkkmkktkkkrkk -4-6 z: tzprqwzzcpj -3-4 w: gblwcxwllzpv -3-5 d: ddcddd -9-13 r: rrfjmrcsrrwvrrk -11-17 m: dgwrmqjmclmczrlwf -1-4 v: vvhvvv -10-13 c: clhccbcvbvcfcccqccc -11-13 s: sssssssssssss -6-7 k: skkckkk -2-5 m: mfffq -3-5 x: jxbxx -1-2 c: ctcc -5-8 q: qqqqgqqqq -11-13 q: hqqbqqqqqqbqqqqqbk -9-11 q: qqqqqqqqqql -15-20 q: qqqqqqqqnqqqqqqqqqqq -5-7 g: gzngbvggmlzzrgx -2-10 n: zjknggzlvnxtbwnhmf -2-13 c: cccccccccccct -4-8 c: cccccccbcccc -3-5 k: kdkkz -8-10 h: nchthhghhjhjh -10-11 l: wllllllllplxllnjj -14-17 q: qqhqqqqqqtqvqcqqqrq -5-9 d: dddddddrz -13-14 z: zzzzzzzzzzzzzm -7-9 t: tttttctwlttt -6-13 w: dwcwdtwrwccwwl -10-11 h: hhhhhwhhmmhhhh -7-9 t: tttttjtttt -12-17 n: nnnnknnfpnnwncnnjn -5-6 c: zccccc -11-13 s: ssssksxssssss -9-17 q: qqqqcfbqrqqcqzqqlqqq -3-4 m: dmml -4-6 v: slvvvln -4-5 n: nnbmnn -2-7 h: whhhhhjvfhhh -2-5 s: slhss -4-5 q: zbhqhqgqdq -2-6 p: pjtxqp -7-9 h: hhhhhhkhh -7-8 w: fgvwcwws -10-13 d: ddddxhdddddvhdddd -7-16 m: mmnznmmwmwrmqzrqbmpr -12-13 v: vvvvvvvvvzvvjv -18-19 g: mztkzhgmndnffztwqfg -7-8 j: jjjcjjvjjjjpjjjjjjj -7-10 s: sssssssssz -18-20 s: sssssssssssssssssssg -1-4 r: trrrr -2-16 r: mrrrrrrhrcrrfcpqrh -5-13 n: nnbljfchnnnnnj -1-6 v: vvvvvmvv -7-15 q: szqhbkqxppcbkxmc -9-10 l: gllllvllsvll -1-4 m: mxldw -5-9 x: xxxxxxxxj -11-16 t: ttttttttwttttttfl -7-12 j: sjjzpjjjjljhj -1-5 x: wmplxj -2-6 z: zzxzzrzqplrh -4-6 w: cqbwwbww -14-15 l: llllltllllllllw -3-4 m: mhmvvz -3-4 w: wwmw -1-4 c: ccchpccc -6-10 p: pppppppppqprbppppp -9-15 h: hhhjcrhhhhhhchhjht -8-11 g: gggggggkggggggggg -4-9 h: hhkqxhhhlh -7-8 f: mlfdfrmfbfttmffqfff -7-9 t: nttttttvsn -6-9 h: hhhhbhvhph -4-5 f: hhcdf -3-4 k: kfxkcr -1-4 z: zzml -3-5 f: cjjffbzffqfsbm -4-5 f: ffdfh -6-17 h: hhhhhhhhhhhhhhhhrh -8-10 d: qdddzddddzdd -7-8 j: nfxxthqj -2-4 n: nnnc -3-5 v: vlvzx -6-10 n: nnnnnnnnns -11-13 q: bzhwhbvwqffzs -3-6 c: gccmcc -2-5 m: xmbgm -2-11 g: tgztmzzbgjzc -2-5 j: jsjbj -3-4 v: vvljvvv -3-6 p: pxwcnwmp -2-7 j: ndjnzmjklxqwpkpnwb -1-20 s: slssswsnssscgbssxsdg -3-4 r: rrrfjc -5-16 t: ttntptttsqtttpwtgbt -3-4 g: fxgg -13-17 l: llltllllllllvllllvrl -5-8 q: vxfpqhqd -4-8 c: cvqcwkccp -5-11 x: kxqkghvxxdqfwxxkxx -4-5 t: tttht -8-11 n: mnnpnnpsnqdknnvsh -1-4 g: gggngpdggv -5-6 s: ssssss -4-7 d: mddfddk -7-8 f: fffffffb -4-11 x: cbmcvvvvxgn -14-16 d: vdddkddpddddllrddddd -8-9 h: qhhhsnxhjmzhlhdjxhf -5-13 f: fxfhlqsffxfgwpcz -14-16 g: jggggnngggngggggjggg -1-5 z: rzgzt -3-6 f: fffgrv -3-4 w: zwwtwdw -9-12 g: dkmhhvhjgsvqglbrr -4-5 g: gbrtx -1-5 r: xrrrr -2-5 d: ddddddddddddddd -4-5 j: jjvjz -2-4 b: blbbbt -16-17 b: bbbbbbbbbbblbbbzbc -8-13 l: lljlqlkslqllllll -6-15 g: wgfgzggggggbtch -4-13 w: cwvbtpnjdkvww -8-10 x: xtdxxxxxxhxxx -3-6 p: pprpppp -15-17 p: ppppppppppppppkpppp -1-3 w: wnwpwwbllb -3-5 m: mxqdq -13-16 s: hsrsssqssssscgssss -1-2 c: zccccm -5-8 r: rrrrkrrm -5-6 j: njjkjjsj -5-10 r: rrrrhrrrrr -5-12 x: xmxwxnmxsldlrpgxxxc -4-6 z: ztzwfzj -11-15 w: wwcwwwwwwwzwwww -5-7 c: cpccccnd -1-16 q: qqvhqhnpqscqqldqbzh -8-9 s: kfpdswzssssqssscms -2-16 l: hppbqldllnlljvflltl -4-12 c: cccccccccccpccc -5-6 r: rrrrqb -11-12 f: ffffdffffmfdkff -5-6 k: lhkkkf -12-15 z: bzzzzzzzzstzzzz -5-13 c: kgsscwsfzcbwchwk -11-18 m: wmmjbmfpvmmmthfwpsxf -7-14 m: mmmfmmtqmmmmmmmmrc -14-15 g: wbqfggngtbqvpqp -10-11 k: kkkvxktjtkbjkkkk -2-4 b: wbtkp -4-10 v: vvvvbffvmtvvz -6-8 m: vtvgmmbc -1-7 d: hddsnzd -2-3 d: rndxchftldndc -2-11 z: zzcwbxkzzqzzp -5-6 q: wqqqjq -9-10 d: ddddddpdcdd -1-12 g: ggfggggggggbn -4-5 v: vvvrvv -12-14 r: rrrrrrrrrrrqrr -6-10 s: sssshvssss -7-10 g: gqgzgggksggggdqghs -8-9 c: ccccccccf -13-18 j: gfjjjjjjjjgjhwjjch -11-15 m: mmmmmmmmmmmmmmm -2-4 s: ssqsr -7-8 v: vxxvbfdgvvgvtw -2-7 x: xwxxxxx -3-5 p: pzppfp -1-2 z: zfzwpzpxzc -6-7 r: vrrxrrnrb -3-4 f: nvftvrjsgxszkfsffg -1-5 w: kndqwltttskcwtzqt -1-9 z: zzzzzzzzzz -10-11 v: vvvvvvvvvvv -1-5 m: gmjhm -7-11 j: sdjjpjjjdgnccjjjsq -1-6 m: rrmcmmmmmbm -1-6 n: nlclfggwnm -3-7 s: clfnmssns -3-7 m: tqjmmmx -13-14 n: nfnvkntnlnnnxfwlnnnn -3-4 p: xphp -8-9 n: nnnlnnnzn -11-12 h: hhhhhhhdhhhhh -1-4 p: pjgsphp -3-9 f: pvfnfmfrcffffjf -15-16 d: dddddddddzddldgdd -2-4 b: bvztgnzbpr -3-7 w: wgwhmpwwwlwzzhwnv -5-9 n: nmznnvnnsznnw -4-6 f: zqffsnffdlbkt -6-7 s: sssssss -2-5 q: kqlqqmv -11-14 q: pjqrzjfdgmqzpd -17-18 s: sssssssssssssssssj -8-12 x: zxxxpxxxxxxt -2-4 h: hqhhhwfshp -1-9 b: qzwgfbzjvt -8-10 c: cccccccccn -3-5 n: nnnkwn -4-6 m: zmmhdzmmx -7-13 v: vvvvvnvvvvvvsvv -1-12 z: zzvzxzfzzrzm -6-11 p: ppppplppppvppppfp -1-5 s: sjsss -2-19 w: wwwwwwwwwwwwwwwwwwcw -5-6 k: zxlkrkbcrcwkdqtkkw -1-4 w: hjjbzqwnpjrbglkr -8-9 n: sznnljnqn -7-13 k: dwkpnjkdkglnm -14-20 x: xzxrxxsxxxxxxxxxxxjx -4-7 w: rtrwdvww -14-18 m: mmmpmmmmmmmmmlmnmq -3-4 z: zzxz -8-10 z: zzzzzzzzzjz -11-14 v: vcvwvxvcslbvvhv -4-8 j: jgjjbrjhp -5-6 d: dddddm -4-5 n: nnnzn -15-16 t: ttttttttttttttnc -5-8 b: bbtbspvbbgllcrgxd -8-9 w: wwwwwwwqw -3-5 j: vbjmxwjgjfrzttznwc -12-14 l: llllllllllnglzlwbl -2-4 f: ntffj -2-4 c: gvccrcc -19-20 w: wwwwwwwwwwwwwwwwwwpw -1-3 k: klwgkc -3-9 s: qsmlssskpsbsscs -8-9 j: jjjjjjjdj -5-9 s: bszlpsssss -13-14 l: llxllhlllllllllll -1-6 s: ssssscs -7-8 v: pbvptdvv -10-15 v: vvvvvvgvvvvvvvcv -4-5 k: kkcskfldskdc -13-14 v: vvvvvvvvvvvvvgv -3-7 n: hnjnnnnnsnfp -3-8 m: mtmjhrzzllqml -9-11 w: wwwwwwwwwwxw -10-20 g: pkvgkfvmxgkpjjhtqvcg -8-11 w: wwwwwwzwwwdw -5-7 r: rrrrrrb -2-7 b: sbldlwvcb -10-17 v: vvvvvvqgcvvkdvsvvjv -4-5 d: tkddnddzqpdfdddd -10-12 p: npppppppppfm -1-12 t: wttttttttttttt -4-5 f: qfffz -11-14 p: ppppppppppppgvpcp -6-8 w: qswwwrwwmww -9-15 g: txgchzlpgggdhgggbg -2-10 h: hthhzhhhshhh -5-8 l: lllllzkk -17-18 l: nlllllllllllllllvll -3-6 c: zdwcjcccdqct -8-17 m: mmmmmmmmmmmmmmmmjm -10-12 c: ccccncrccccb -4-12 j: jjjbjjjjjjnwjj -2-6 h: chbhhfc -5-6 c: cccpncc -6-7 m: dmwmkmphmmdmm -6-7 k: rxwkmkv -1-5 f: fzgfl -4-7 x: dxkmxhb -1-5 f: hhfzfpfffffsff -1-7 s: sssslsvv -3-7 w: wgwwwsh -12-15 d: mdsdbkltdvthvfjdddn -16-18 x: xxxxxxxxxxxxxxxxtl -5-19 x: xwxxxxxxxxxxxxxxbpn -3-5 h: hhrfh -8-10 g: ggggggggggkgg -3-8 c: cccccccmc -5-7 r: wrrrxrrr -7-8 p: phpprdslbpxprpg -17-19 z: zzzzvzzzzzdzzzzzzzg -2-4 x: kxxxxxm -2-11 w: gwwzpwwwwwplrqfh -6-9 t: qtcttttgf -9-12 g: gggggggggggsg -3-6 n: fzmnxb -5-9 x: pqxxxwdtn -5-6 j: jjjjjkq -10-12 h: hhhhhdhhhzhh -1-4 g: gskgk -3-5 c: ccccj -1-10 m: wmxsgmzmrzmrmmmjmmct -5-10 p: lmpppvptdgpjpwfwpp -2-4 z: bzgm -6-7 d: ddzdddj -3-7 r: gchrfwr -4-7 k: kkcvkkkkkk -8-12 t: tpwtttctvtttftpt -11-12 c: ccccccxcdncbwcc -2-10 p: jwwxlppppppnpn -9-16 w: chmwwwwwjwrwjwzjww -1-6 j: jkqjjbj -5-8 k: kkkkkklhkk -3-5 q: qqqqc -16-17 x: xxxxxxxxxxxxxxxtg -4-9 f: fmfkcfffffkcfmfhnzf -5-6 z: zhzzlz -4-17 k: kbwmwvkkvvhxkkkckqvk -3-5 d: dddmmdt -4-10 m: mmmmmmmmms -5-6 g: ghgggpj -1-5 c: cccck -3-7 z: zzjzzzzz -2-7 v: xrprnvvtsrgsk -1-5 s: sqqsn -3-5 j: xwpnj -5-7 v: vvvvvvqmv -4-5 j: jjjjzjjjjljjc -2-4 h: hghh -3-5 n: fnnpc -16-20 d: dddddddzdddddddpdddd -3-4 t: tnpt -2-7 f: fxffffkff -6-9 b: bbbhbbwhbbrblmtb -7-10 m: msmxmrnmrmmmm -3-4 r: rrzrr -7-8 m: mgmmmmjmm -2-3 l: lmll -2-6 h: cngphhhbfpvvsgrqhhzq -6-8 d: dddddddg -12-15 p: vfjxwpcpdvpnjwp -12-17 m: mzfmmsvfxmqsmcfjmwjb -15-19 b: bbbbbfbbbbbsbbmbbbbb -7-8 n: qdnjnnnpvmfnn -6-8 l: llllllll -3-4 n: nnbdh -11-12 w: hprdhfrpvcwbgwjcw -2-7 r: jrfrbjrhrw -1-6 v: fvzknvvv -10-11 t: tttstdhttqrttt -5-14 f: fxffnffffnfffff -10-13 q: qqqqqqqqqjqqqqq -1-5 v: tnvfvxvjvbvjk -4-5 c: ccccpc -4-6 t: tttttktttt -1-2 r: rwrsq -11-12 c: cccggjcccccr -11-16 g: gwggggggggqggbgggfg -12-14 b: bbggzhxsjjsbsf -5-7 r: kjdwpfbmcptrslrrr -1-2 l: lvbl -6-11 c: hsksgzhccbccbdfnzqcv -6-7 m: gmmmmmc -1-2 h: hhhh -1-3 g: rggg -4-8 z: rzzzzfbwzxkzzz -3-6 w: wwwwww -3-4 g: ggwtg -9-11 v: wxfltmvjvjm -2-4 l: llck -2-3 m: mmkgpdwzdm -2-5 d: bdjhdhjldzh -10-12 j: jnjlmjjjjpcdkjjjx -3-9 q: qqzqqqqqqqqqq -4-8 d: ddzwdpddd -3-7 m: mzmbsmcjgmpmmdkmr -8-13 q: xrxvgqdvvmjhhgdfz -3-12 z: zzjzzzzzzzzzzz -5-10 k: jkkkmkkkmkk -6-7 m: mmllmmtm -17-19 c: ccccccccccccccnckccc -6-9 w: wwwtbrwwwxww -7-9 d: wfdkwddsdsmdbswv -11-12 g: ggggggggggbgg -13-14 j: prjjdjjjjjjjcjjj -3-5 j: jjlljv -3-4 h: hrlh -6-7 l: hplnxlsjnwxzllllljcj -4-5 g: gfgml -4-5 z: zwkznzn -4-11 n: stnzhznnfnqcnn -2-5 h: hmzhh -4-6 w: wwbwwc -4-11 w: vmwwrxpkwcp -4-8 t: thxttstmtbstcvjtlflh -6-8 v: hvvkvvhfm -16-18 b: tbbbbbbbbbbbbbbbbr -8-10 f: fffffffcfl -13-15 r: rrrdrrrrrrrrrbr -8-14 t: ztstxttttttttwz -8-12 j: jgjjjjgjjjjx -5-6 m: nmqjdmgfqqmcmmvndztl -2-6 v: vwvvvvtv -15-16 l: llllllllllllllll -3-10 q: qqqqqqqqqxqq -8-9 j: rggxhvjjjk -1-3 p: pqhp -4-11 z: nkjddzczjrzktvnckmg -5-12 r: tfrdrswgwnbc -8-13 r: rrrrrrrrrrrrrr -13-18 x: xxmxvxxxxxxxhrxxxc -7-8 z: zzkzzzzw -4-8 m: mmmqmmskqlmmgm -1-3 w: bmwg -1-4 z: vzzzzzwz -3-4 d: dqdw -2-9 z: hzhqpndtllsw -10-13 t: tttttttttttbjb -12-14 r: rrrxrrsrrrgfrrr -12-19 g: hdxnlgglxwrgzkggcwp -3-4 x: qxjx -1-2 r: rrpdlqhcnwwr -5-11 c: vdbzvccdccldsjcq -4-6 k: kxkwkk -16-18 k: kkkknkkkkkkkfkkkkx -1-2 q: tqtghddbk -7-8 g: ggcgggvgg -13-19 d: ddddddfjdddddfddddd -9-15 z: pzhzzzzzqpzzzzzz -4-5 l: lclld -2-15 r: jrrmtzrxlczbttrcvkn -3-5 z: zzzzc -15-16 k: kkkckkdjnkkkkkkkkk -11-13 m: mmmmmmmmwmmmzm -8-13 p: ppdpptppdppxkppppppp -1-3 g: gszcmgjg -5-11 h: skbchhdbnphpbfl -4-7 d: prdjctk -15-18 f: ffcffffffffffzdffc -7-11 g: npggtwgzgtgzhx -12-14 m: mmmmmmmmmmmpmkm -10-11 b: bbbbbbbbbbb -3-16 k: kgxtvmlgpkptpghkb -4-6 m: zcwmzmvqvgmmsxj -6-15 m: mzmmccmmlmmrmlnl -12-13 x: xxxxxxxxwxxxz -4-5 d: mhvdtxfklzdpgdqdpqhd -5-10 g: nghgggggggqg -7-9 k: kkkkfkkkwk -6-7 c: cvcvczncn -10-11 t: tttqttttttv -18-20 h: hfsqhkwfhttgfhmbghhx -6-7 v: vgvvvwz -3-4 z: zzzj -3-5 d: dhqjnhgldtdzx -3-4 b: jbrbbbbbbbblwb -12-15 g: gsgfdfksrggqvgggjgt -6-11 p: pmppnpqpdppdpppphpf -13-14 z: zzzzgzbzzzzzgzz -4-12 c: ccjcrvcnwccwctcczcp -10-11 c: szcccfccfpcchqs -10-14 l: lllllltgjlnlbprlll -12-17 z: zhzzzxzpzzzfzzzqznz -12-15 l: llllllllmvlvllfll -7-12 c: ccccccncccccc -1-5 m: mhmmzmm -11-17 r: rrzrrwrrsrcrsmdrvrr -4-5 w: fwwpwfw -7-8 n: nnnnnnnk -3-18 n: rxhzsscgbnmzpvbqmzf -4-11 k: kkkkkkkkkkkxkkskkkdz -10-11 c: cccccccccckcccccc -8-15 r: zrrtfrjrrrrrjrrrrrr -15-16 h: ghgvlhwgqslhhhhxmp -3-5 f: ffffqf -3-8 s: bssmfsgspxssgjhsjdv -3-5 q: bfdhq -4-7 k: qknkkkd -6-9 b: bbbtbnfbbb -12-14 x: xxxxxxxqxkxvxxwxxcw -3-6 c: chfckc -3-8 h: kzkhgrffz -10-16 f: fffgjfffsvffdzfhfzff -1-3 r: rgcr -16-17 x: xxxxxdxxxxxxxxxxl -6-11 j: rsjcjjcbpchkvfjpml -9-10 s: sssqvsssjsss -17-18 v: vvvvvvvvvvvvvvvvvv -3-5 t: jtmtgtxxhzskzk -1-6 t: ttqkvdgs -13-16 q: qqqqqqhqqqqqzqqjqq -10-11 b: bbbbbvbbbbw -6-7 w: sgwmqwgwtbrllf -10-11 f: ffffffftffff -12-13 w: wwwwwwwwwwwzt -18-19 t: ttttttttttttttttttt -1-5 h: zghhr -1-2 v: dvjnctwvlp -1-2 j: jhzkzjh -3-6 h: rhhbhhh -2-4 d: dddrd -17-18 s: ssssssssssssssssns -1-8 m: smmmmmmmm -2-4 s: dcfsbzwqq -11-12 d: vnldqthkptgkkfdmtw -8-12 p: vpppzpprppppp -6-8 q: jqqqsphqjwrqj -8-10 k: ktkkkkdkkkk -4-12 v: nvvwvvvjzvvvv -5-6 z: zzzzzt -1-5 w: xwwwwwwww -11-14 p: pppfbpppkpftdpkpgpp -2-3 v: zrlv -2-4 f: fbwff -5-6 s: ssssmn -11-12 z: zzwztpzpjzhz -5-6 c: cccjcc -4-6 v: vvvgpvcpwv -5-6 j: jnzcpjnzjjcpsjfps -12-14 m: tpzwjjgpbbdmgxgphd -13-15 n: nznnnncnnnnnnnf -8-11 w: qsxwnlhwwxw -6-9 t: ltbdttnst -10-12 t: hnjdfgrhtgkl -2-4 d: dbddddc -13-14 g: gggggggbgggmgmgm -4-12 r: rrrzrgkrrrrkr -14-17 n: nnhnnnnnnnnnnnnnhnn diff --git a/2020/day1.cpp b/2020/days/day1.cpp similarity index 87% rename from 2020/day1.cpp rename to 2020/days/day1.cpp index 5eda877..03d3b48 100644 --- a/2020/day1.cpp +++ b/2020/days/day1.cpp @@ -30,7 +30,8 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" // Find 2 numbers that sum to 2020 auto find_2020_x2(const std::vector & list) -> void { @@ -44,7 +45,7 @@ auto find_2020_x2(const std::vector & list) -> void { --end; } } - std::cout << (list[begin] * list[end]) << std::endl; + print((list[begin] * list[end])); } // Find 3 numbers that sum to 2020 @@ -53,13 +54,13 @@ auto find_2020_x3(const std::vector & list) -> void { for (auto n1 = 1; n1 < list.size() - 1; ++n1) { auto low = n0 + 1; auto high = n1; - auto n2 = (low + high) / 2; - while (low < high - 1) { + while (low < high) { + auto n2 = (low + high) / 2; auto sum = 0; if ((sum = list[n0] + list[n1] + list[n2]) == 2020) { - std::cout << (list[n0] * list[n1] * list[n2]) << std::endl; + print((list[n0] * list[n1] * list[n2])); return; - } else if (sum > 2020) { + } else if (sum < 2020) { low = n2 + 1; } else { high = n2; @@ -69,11 +70,11 @@ auto find_2020_x3(const std::vector & list) -> void { } } -auto main(i32 argc, char * argv[]) -> i32 { +auto day1() -> void { auto list = std::vector(); { auto line = std::string(); - auto file = std::ifstream("day1.input"); + auto file = std::ifstream("inputs/day1.input"); while (getline(file, line)) { list.push_back(std::stoi(line)); } @@ -82,6 +83,4 @@ auto main(i32 argc, char * argv[]) -> i32 { find_2020_x2(list); find_2020_x3(list); - - return 0; } diff --git a/2020/day10.cpp b/2020/days/day10.cpp similarity index 91% rename from 2020/day10.cpp rename to 2020/days/day10.cpp index 9f6fab4..0da5b83 100644 --- a/2020/day10.cpp +++ b/2020/days/day10.cpp @@ -29,7 +29,8 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" struct Pair { u64 jolt; @@ -40,11 +41,11 @@ auto operator<(const Pair & left, const Pair & right) -> bool { return left.jolt < right.jolt; } -auto main(i32 argc, char * argv[]) -> i32 { +auto day10() -> void { auto jolts = std::vector{{ 0, 1 }}; { auto line = std::string(); - auto file = std::ifstream("day10.input"); + auto file = std::ifstream("inputs/day10.input"); while (getline(file, line)) { jolts.push_back({ (u64) std::stoll(line), 0 }); } @@ -59,7 +60,7 @@ auto main(i32 argc, char * argv[]) -> i32 { else if (jolts[i + 1].jolt - jolts[i].jolt == 3) ++dif3; } - std::cout << (dif1 * dif3) << std::endl; + print((dif1 * dif3)); for (auto i = i32(0); i < jolts.size() - 1; ++i) { for (auto j = i + 1; j < jolts.size(); ++j) { @@ -70,7 +71,5 @@ auto main(i32 argc, char * argv[]) -> i32 { } } } - std::cout << jolts[jolts.size() - 1].count << std::endl; - - return 0; + print(jolts[jolts.size() - 1].count); } diff --git a/2020/day11.cpp b/2020/days/day11.cpp similarity index 94% rename from 2020/day11.cpp rename to 2020/days/day11.cpp index c5aaa78..ecbd826 100644 --- a/2020/day11.cpp +++ b/2020/days/day11.cpp @@ -30,7 +30,8 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" template auto iterate_seats(const auto & seats, Lambda callback) { @@ -62,12 +63,12 @@ auto count_seats(const auto & seats) -> usize { return occupied; } -auto main(i32 argc, char * argv[]) -> i32 { +auto day11() -> void { auto bit = u8(0b1); auto seats = std::array, 2>(); { auto line = std::string(); - auto file = std::ifstream("day11.input"); + auto file = std::ifstream("inputs/day11.input"); while (getline(file, line)) { seats[bit].push_back(line); } @@ -94,7 +95,7 @@ auto main(i32 argc, char * argv[]) -> i32 { } while (!seats_equal(seats)); - std::cout << count_seats(seats[0]) << std::endl; + print(count_seats(seats[0])); iterate_seats(seats[0], [&seats](i32 i, i32 j) { seats[0][i][j] = seats[1][i][j] = 'L'; @@ -129,7 +130,5 @@ auto main(i32 argc, char * argv[]) -> i32 { }); } while (!seats_equal(seats)); - std::cout << count_seats(seats[0]) << std::endl; - - return 0; + print(count_seats(seats[0])); } diff --git a/2020/day2.cpp b/2020/days/day2.cpp similarity index 91% rename from 2020/day2.cpp rename to 2020/days/day2.cpp index cec8af6..fa57af9 100644 --- a/2020/day2.cpp +++ b/2020/days/day2.cpp @@ -29,7 +29,8 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" struct Password { u32 min; @@ -72,11 +73,11 @@ auto count_valid_toboggan(const std::vector & passwords) -> u32 { return valid; } -auto main(i32 argc, char * argv[]) -> i32 { +auto day2() -> void { auto passwords = std::vector(); { auto line = std::string(); - auto file = std::ifstream("day2.input"); + auto file = std::ifstream("inputs/day2.input"); while (getline(file, line)) { auto index = usize(0); auto password = Password{}; @@ -88,8 +89,6 @@ auto main(i32 argc, char * argv[]) -> i32 { } } - std::cout << count_valid_sled(passwords) << std::endl; - std::cout << count_valid_toboggan(passwords) << std::endl; - - return 0; + print(count_valid_sled(passwords) ); + print(count_valid_toboggan(passwords)); } diff --git a/2020/day3.cpp b/2020/days/day3.cpp similarity index 60% rename from 2020/day3.cpp rename to 2020/days/day3.cpp index 4c6268b..647d627 100644 --- a/2020/day3.cpp +++ b/2020/days/day3.cpp @@ -29,40 +29,53 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" -auto read_field_and_count_trees(std::vector & trees, usize horizontal_increment, usize vertical_increment) -> u64 { - auto tree_count = u64(0); +struct TreeVector{ usize horz; usize vert; }; +struct Coordinate{ usize x_index; usize y_index; }; - auto x_index = usize(-horizontal_increment); - auto y_index = usize(-1); - auto line = std::string(); - auto file = std::ifstream("day3.input"); - - while (getline(file, line)) { - auto vertical_check = (++y_index % vertical_increment == 0); - tree_count += vertical_check * (line[(x_index += (vertical_check * horizontal_increment)) % line.size()] == '#'); +auto read_field_and_count_trees(const std::vector & vectors) -> std::vector { + auto tree_counts = std::vector(vectors.size()); + auto coords = std::vector(vectors.size()); + for (auto i = usize(0); i < coords.size(); ++i) { + coords[i] = { usize(-vectors[i].horz), usize(-1) }; } - return tree_count; + auto line = std::string(); + auto file = std::ifstream("inputs/day3.input"); + + while (getline(file, line)) { + for (auto i = usize(0); i < vectors.size(); ++i) { + auto & vector = vectors[i]; + auto & coord = coords[i]; + + auto vertical_check = (++coord.y_index % vector.vert == 0); + tree_counts[i] += vertical_check * (line[(coord.x_index += (vertical_check * vector.horz)) % line.size()] == '#'); + } + } + + return std::move(tree_counts); } -auto main(i32 argc, char ** argv) -> i32 { +auto day3() -> void { auto trees = std::vector(); - auto tree_counts = std::vector(); + auto tree_counts = read_field_and_count_trees( + std::vector{ + { 3, 1 }, + { 1, 1 }, + { 5, 1 }, + { 7, 1 }, + { 1, 2 }, + } + ); - tree_counts.push_back(read_field_and_count_trees(trees, 3, 1)); - std::cout << tree_counts[0] << std::endl; + print(tree_counts[0]); - tree_counts.push_back(read_field_and_count_trees(trees, 1, 1)); - tree_counts.push_back(read_field_and_count_trees(trees, 5, 1)); - tree_counts.push_back(read_field_and_count_trees(trees, 7, 1)); - tree_counts.push_back(read_field_and_count_trees(trees, 1, 2)); auto tree_count_product = u64(1); for (auto tree_count : tree_counts) { tree_count_product *= tree_count; } - std::cout << tree_count_product << std::endl; - return 0; + print(tree_count_product); } diff --git a/2020/day4.cpp b/2020/days/day4.cpp similarity index 95% rename from 2020/day4.cpp rename to 2020/days/day4.cpp index f0c5b78..1ba17f8 100644 --- a/2020/day4.cpp +++ b/2020/days/day4.cpp @@ -29,7 +29,8 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" struct KeyValue { std::string key; @@ -46,13 +47,13 @@ auto try_num(const std::string & passport, usize index) -> bool { return Min <= num && num <= Max; }; -auto main(i32 argc, char * argv[]) -> i32 { +auto day4() -> void { auto valid_count1 = usize(0); auto valid_count2 = usize(0); auto passport = std::string(); auto line = std::string(); - auto file = std::ifstream("day4.input"); + auto file = std::ifstream("inputs/day4.input"); while (getline(file, line)) { if (line == "") { auto elements = std::vector{ @@ -108,7 +109,6 @@ auto main(i32 argc, char * argv[]) -> i32 { } } - std::cout << valid_count1 << ", " << valid_count2 << std::endl; - - return 0; + print(valid_count1); + print(valid_count2); } diff --git a/2020/day5.cpp b/2020/days/day5.cpp similarity index 90% rename from 2020/day5.cpp rename to 2020/days/day5.cpp index 70d3d35..5a68158 100644 --- a/2020/day5.cpp +++ b/2020/days/day5.cpp @@ -30,12 +30,13 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" -auto main(i32 argc, char * argv[]) -> i32 { +auto day5() -> void { auto seat = usize(0); auto line = std::string(); - auto file = std::ifstream("day5.input"); + auto file = std::ifstream("inputs/day5.input"); auto seats = std::vector(); @@ -49,16 +50,14 @@ auto main(i32 argc, char * argv[]) -> i32 { } seats.push_back(local_seat); } - std::cout << seat << std::endl; + print(seat); std::sort(seats.begin(), seats.end()); for (auto i = usize(0); i < seats.size() - 1; ++i) { if (seats[i] + 2 == seats[i + 1]) { - std::cout << (seats[i] + 1) << std::endl; + print((seats[i] + 1)); break; } } - - return 0; } diff --git a/2020/day6.cpp b/2020/days/day6.cpp similarity index 91% rename from 2020/day6.cpp rename to 2020/days/day6.cpp index ae1035b..b3a3dbe 100644 --- a/2020/day6.cpp +++ b/2020/days/day6.cpp @@ -29,12 +29,13 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" -auto main(i32 argc, char * argv[]) -> i32 { +auto day6() -> void { { auto line = std::string(); - auto file = std::ifstream("day6.input"); + auto file = std::ifstream("inputs/day6.input"); auto answers = std::vector(26); @@ -57,8 +58,7 @@ auto main(i32 argc, char * argv[]) -> i32 { } } } - std::cout << sum_1 << ", " << sum_2 << std::endl; + print(sum_1); + print(sum_2); } - - return 0; } diff --git a/2020/day7.cpp b/2020/days/day7.cpp similarity index 93% rename from 2020/day7.cpp rename to 2020/days/day7.cpp index 97991ea..8c2d8cc 100644 --- a/2020/day7.cpp +++ b/2020/days/day7.cpp @@ -32,7 +32,8 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" struct SubBag { std::string type; u32 count; }; @@ -60,11 +61,11 @@ auto count_to(const std::string & search, std::map & map) -> return counted; } -auto main(i32 argc, char * argv[]) -> i32 { +auto day7() -> void { auto bag_graph = std::map(); { auto line = std::string(); - auto file = std::ifstream("day7.input"); + auto file = std::ifstream("inputs/day7.input"); while (getline(file, line)) { auto find = line.find("bag") - 1; auto bag_type = line.substr(0, line.find("bag") - 1); @@ -96,9 +97,7 @@ auto main(i32 argc, char * argv[]) -> i32 { } } } - std::cout << seen.size() << std::endl; + print(seen.size()); - std::cout << (count_to("shiny gold", bag_graph) - 1) << std::endl; - - return 0; + print((count_to("shiny gold", bag_graph) - 1)); } diff --git a/2020/day8.cpp b/2020/days/day8.cpp similarity index 94% rename from 2020/day8.cpp rename to 2020/days/day8.cpp index 030bceb..0d770cd 100644 --- a/2020/day8.cpp +++ b/2020/days/day8.cpp @@ -29,7 +29,8 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" enum OpCode { Acc, Jmp, Nop }; struct Op{ OpCode code; i32 num; bool executed; }; @@ -81,11 +82,11 @@ auto attempt_swap(State & state, std::vector & ops) -> bool { return false; } -auto main(i32 argc, char * argv[]) -> i32 { +auto day8() -> void { auto ops = std::vector(); { auto line = std::string(); - auto file = std::ifstream("day8.input"); + auto file = std::ifstream("inputs/day8.input"); while (getline(file, line)) { ops.push_back(extract_op(line)); } @@ -95,18 +96,16 @@ auto main(i32 argc, char * argv[]) -> i32 { while (!ops[state.isp].executed) { execute(state, ops); } - std::cout << state.acc << std::endl; + print(state.acc); for (auto & op : ops) { op.executed = false; } state = State{ 0, 0 }; for (;;) { if (attempt_swap(state, ops)) { - std::cout << state.acc << std::endl; + print(state.acc); break; } execute(state, ops); } - - return 0; } diff --git a/2020/day9.cpp b/2020/days/day9.cpp similarity index 92% rename from 2020/day9.cpp rename to 2020/days/day9.cpp index 1668fd5..987fc9c 100644 --- a/2020/day9.cpp +++ b/2020/days/day9.cpp @@ -29,7 +29,8 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" auto find_sum(usize index, std::vector xmas) { for (auto i = index - 25; i < index - 1; ++i) { @@ -42,10 +43,10 @@ auto find_sum(usize index, std::vector xmas) { return false; } -auto main(i32 argc, char * argv[]) -> i32 { +auto day9() -> void { auto xmas = std::vector(); auto line = std::string(); - auto file = std::ifstream("day9.input"); + auto file = std::ifstream("inputs/day9.input"); while (getline(file, line)) { xmas.push_back(std::stoll(line)); } @@ -53,7 +54,7 @@ auto main(i32 argc, char * argv[]) -> i32 { auto invalid = u64(0); for (auto i = usize(25); i < xmas.size(); ++i) { if (!find_sum(i, xmas)) { - std::cout << (invalid = xmas[i]) << std::endl; + print((invalid = xmas[i])); break; } } @@ -82,7 +83,5 @@ auto main(i32 argc, char * argv[]) -> i32 { max = xmas[i]; } } - std::cout << (min + max) << std::endl; - - return 0; + print((min + max)); } diff --git a/2020/day10.input b/2020/inputs/day10.input similarity index 100% rename from 2020/day10.input rename to 2020/inputs/day10.input diff --git a/2020/day11.input b/2020/inputs/day11.input similarity index 100% rename from 2020/day11.input rename to 2020/inputs/day11.input diff --git a/2020/day3.input b/2020/inputs/day3.input similarity index 100% rename from 2020/day3.input rename to 2020/inputs/day3.input diff --git a/2020/day4.input b/2020/inputs/day4.input similarity index 100% rename from 2020/day4.input rename to 2020/inputs/day4.input diff --git a/2020/day5.input b/2020/inputs/day5.input similarity index 100% rename from 2020/day5.input rename to 2020/inputs/day5.input diff --git a/2020/day6.input b/2020/inputs/day6.input similarity index 100% rename from 2020/day6.input rename to 2020/inputs/day6.input diff --git a/2020/day7.input b/2020/inputs/day7.input similarity index 100% rename from 2020/day7.input rename to 2020/inputs/day7.input diff --git a/2020/day8.input b/2020/inputs/day8.input similarity index 100% rename from 2020/day8.input rename to 2020/inputs/day8.input diff --git a/2020/day9.input b/2020/inputs/day9.input similarity index 100% rename from 2020/day9.input rename to 2020/inputs/day9.input diff --git a/2020/template.cpp b/2020/misc/day.cpp.template similarity index 91% rename from 2020/template.cpp rename to 2020/misc/day.cpp.template index 51a940b..52dfe9d 100644 --- a/2020/template.cpp +++ b/2020/misc/day.cpp.template @@ -29,16 +29,15 @@ #include #include -#include "types.hpp" +#include "../misc/types.hpp" +#include "../misc/print.hpp" -auto main(i32 argc, char * argv[]) -> i32 { +auto current_day() -> void { { auto line = std::string(); - auto file = std::ifstream("dayNUM.input"); + auto file = std::ifstream("inputs/current_day.input"); while (getline(file, line)) { } } - - return 0; } diff --git a/2020/misc/main.cpp b/2020/misc/main.cpp new file mode 100644 index 0000000..c4752db --- /dev/null +++ b/2020/misc/main.cpp @@ -0,0 +1,36 @@ +/******************************************************************************* + * + * Copyright (c) 2020 Gnarwhal + * + * ----------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files(the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +#include "types.hpp" + +extern auto current_day() -> void; + +auto main(i32 argc, char * argv[]) -> i32 { + current_day(); + + return 0; +} + diff --git a/2020/misc/main_test.cpp b/2020/misc/main_test.cpp new file mode 100644 index 0000000..0d8954d --- /dev/null +++ b/2020/misc/main_test.cpp @@ -0,0 +1,66 @@ +/******************************************************************************* + * + * Copyright (c) 2020 Gnarwhal + * + * ----------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files(the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +#include +#include +#include + +#include "types.hpp" + +extern auto current_day() -> void; + +auto main(i32 argc, char * argv[]) -> i32 { + auto TEST_CYCLES = 1; + if (argc >= 2) { + TEST_CYCLES = std::stoi(argv[1]); + } + + std::cout << "Starting test with " << TEST_CYCLES << " iterations..." << std::endl; + auto begin1 = std::chrono::high_resolution_clock::now(); + + for (auto i = usize(0); i < TEST_CYCLES; ++i) { + current_day(); + } + + auto end1 = std::chrono::high_resolution_clock::now(); + + if (argc >= 3) { + if (argv[2] == std::string("millis")) { + std::cout << "Tests completed in " << std::chrono::duration_cast(end1 - begin1).count() << " milliseconds"<< std::endl; + } else if (argv[2] == std::string("nanos")) { + std::cout << "Tests completed in " << std::chrono::duration_cast(end1 - begin1).count() << " nanoseconds"<< std::endl; + } else if (argv[2] == std::string("micros")) { + std::cout << "Tests completed in " << std::chrono::duration_cast(end1 - begin1).count() << " microsenconds"<< std::endl; + } else { + std::cout << "Unkown time scale '" << argv[2] << "'" << std::endl; + } + } else { + std::cout << "Tests completed in " << std::chrono::duration_cast(end1 - begin1).count() << " microseconds"<< std::endl; + } + + return 0; +} + diff --git a/2020/misc/print.hpp b/2020/misc/print.hpp new file mode 100644 index 0000000..5960cd8 --- /dev/null +++ b/2020/misc/print.hpp @@ -0,0 +1,31 @@ +/******************************************************************************* + * + * Copyright (c) 2020 Gnarwhal + * + * ----------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files(the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +#ifndef TEST_BUILD +#define print(x) std::cout << (x) << std::endl +#else +#define print(x) +#endif diff --git a/2020/types.cpp b/2020/misc/types.cpp similarity index 100% rename from 2020/types.cpp rename to 2020/misc/types.cpp diff --git a/2020/types.hpp b/2020/misc/types.hpp similarity index 100% rename from 2020/types.hpp rename to 2020/misc/types.hpp