From 59293af2d77a6bd540a55788d3fec54763a5831a Mon Sep 17 00:00:00 2001 From: Sloane Perrault Date: Wed, 21 Sep 2022 09:19:52 -0400 Subject: [PATCH] solve: day 2, part 1 --- 2020/02/README.md | 5 + 2020/02/input.txt | 1000 +++++++++++++++++++++++++++++++++++++++++++++ 2020/02/part1.hs | 35 ++ 2020/README.md | 7 +- 4 files changed, 1044 insertions(+), 3 deletions(-) create mode 100644 2020/02/README.md create mode 100644 2020/02/input.txt create mode 100755 2020/02/part1.hs diff --git a/2020/02/README.md b/2020/02/README.md new file mode 100644 index 0000000..0746f57 --- /dev/null +++ b/2020/02/README.md @@ -0,0 +1,5 @@ +# Day 2 + +## Part 1 + +Spent some time reading up on how to define a custom instance of `Read`. Pretty simple otherwise. Surprised `countElem` isn't in Prelude. diff --git a/2020/02/input.txt b/2020/02/input.txt new file mode 100644 index 0000000..2da5b54 --- /dev/null +++ b/2020/02/input.txt @@ -0,0 +1,1000 @@ +2-6 c: fcpwjqhcgtffzlbj +6-9 x: xxxtwlxxx +5-6 w: wwwwlwwwh +7-10 q: nfbrgwqlvljgq +2-3 g: gjggg +9-11 q: qqqqqqnqgqq +14-20 b: bbbbbbbbbbbbzwbbbbbb +2-6 s: sjsssss +4-13 b: mdbctbzgcpdjbhsdctrd +5-6 t: tttttt +7-9 h: zbhhfmwhhpxh +3-4 t: ttmt +4-6 j: jjjjjj +12-13 w: wwwwwwwwwwwwkw +3-4 f: sgbmjfftf +11-12 p: pdppppppppcppp +5-9 q: qqqqqvsqdjq +5-8 j: qsljqmxwk +1-7 w: gwvktwwwkwwww +2-3 w: gvwcvrggjbk +1-4 d: kddd +13-14 k: zkkpkkkkkksskp +2-5 w: wwwwfw +4-5 n: bnrnlnnkdvhbnnj +7-17 s: kswscfssbssztsgwmdr +9-14 h: hhhhhhhvhhhhhbhhhhh +1-2 s: sgvmzrpssss +1-4 x: xxvgbxwxqx +5-9 b: bbbbbbqbdbbzbxb +6-10 d: ndddkqdddd +8-9 z: zzqvkhpzzhx +10-11 k: jrktpgkvkqk +2-4 l: lklf +14-16 c: cxqccccccccccctccc +1-2 g: bsmmpkmd +4-16 q: vmqdqktlqqnhzqqx +6-12 k: kqkwkktfbklkjnkqrtmb +15-16 v: vvvvvvvvvvvvvvxt +12-13 r: rrrrrrsrrrrrx +5-7 p: ppbqlppppp +5-8 s: dxmsqssk +3-4 m: mxmlmm +6-7 c: kcfcbhcc +4-6 z: zzzxzxz +12-14 r: rrrrmrrrrrrrrkkltr +4-6 j: zhbtgg +5-7 r: rrdrrrzrr +1-3 x: rxcxxxxxxxxxxxxx +5-7 g: ggggggvgmcg +12-15 n: nnnnnnnnnnnnnnhn +4-6 p: qppppppp +9-12 j: pjjsmbjjjjjj +3-16 b: bhgbtjhqvkpgcbgbpbz +2-7 q: mqfhknwswqjxjncxjt +6-16 c: wclpphqjcmbzdwccp +13-15 k: dkkdkkkkkkkknkkcn +7-9 b: blfbbbhvz +14-18 w: wwwwwwwvwvwwwwwwwc +11-18 w: xstwwbwwwwwwtrbwww +3-14 z: zdgxzpvzjztfzzrpjz +7-10 j: mjrxjstdnj +10-13 f: ffrfqflffftjkf +1-4 j: jnjtjfj +8-9 g: wtbqjjggjfcvgs +2-7 z: qpwvvjcpzf +3-4 k: kfgk +6-12 l: lllllllllllw +14-15 n: nnnnnnnnnnnnnpr +10-11 p: prcpwdzmcqp +12-14 v: vvvrvvvqvvvschvvzvv +1-11 q: jqqqkfqqqqqqqqwqq +11-12 j: jjjjjjjjjjtj +2-6 x: nqxxxx +7-17 s: blbvqsssssssnslgswz +9-10 s: ssssssssbsss +1-2 t: ttvqtt +3-8 w: bsddhgwb +1-2 r: jrxdfg +8-9 j: ljjjjjjljfmj +1-3 j: jjjjjjjjjdkjj +4-13 f: jfffmsffmfxrmhnf +1-4 s: sswvjx +4-8 b: btfgtwkvdfqkwv +2-3 p: tptddqdkgdfcbxxrpv +1-4 p: dspz +14-16 d: ddddhdvdddddtddh +6-9 l: hnvrpllsl +4-5 h: hjhzhnh +3-10 b: zsvjzttjnbbgdt +12-15 c: ccjscwcccdcccccl +1-9 j: xjjjkjjlj +1-9 m: gngmvxqmmmmhmmml +9-10 k: kkkkkkkkpc +13-14 q: qrsxtpgpnhcrkq +3-6 k: pkjcks +1-3 t: ttjtt +10-15 f: sjwnfftrffptbqltg +3-4 b: nwbtnz +5-7 k: kkkkkkdk +14-18 l: lglllllllllllllllrpl +1-14 q: fqqqqqqdqqqqvd +16-18 p: pppppppppppppppppn +3-7 l: lllllgvx +2-5 b: pbbkcbbbbbg +7-9 c: bcnjkzxccl +4-5 x: cwxxfxtmqtxxp +10-11 d: dddddwcxdvddbdddd +3-5 v: vvvvlvv +4-7 m: mmmmmltldmmmbk +13-14 s: sssssssssssssks +4-6 s: ssslszs +15-16 z: dzbzfxmpzhrrszzf +5-12 x: xrzxxxgxtcxxxxxx +17-19 g: ggggggggggggggxwjgq +12-13 n: nnnnnnhnnnnjn +8-10 l: llllllltllldlll +9-14 t: fttftqttmtkstdf +4-11 l: nnlljlhllllx +5-7 q: qhpzqjl +2-6 v: fglnsvvwlpx +2-3 b: mbvbb +4-9 w: wwqwwwjwmz +1-4 j: jjxpmsk +6-8 c: pckczdcccncr +3-6 x: xbslxxzhqn +11-17 j: jdkjkjjjjbjxjjjjsj +4-8 h: hphbzhjh +12-14 x: xxxxxrxxxxxxxrx +2-4 q: kqgm +1-14 r: lrtrzrrrsrrzrr +5-15 w: tpwwwbdlbxczwcgwnvbw +1-4 p: qppsppp +1-9 z: zzzzzzzzzzzzzz +8-12 t: tttttttbttst +2-3 n: bkfn +5-8 w: xwwwwwwdw +9-10 c: csdccccqcgcbxcn +3-5 v: mvfvvqvvm +2-5 r: rrstrnzfrdwrvbpfqz +1-4 m: mmmmmmmmmmmmmmmmm +8-9 m: mmmmmmmmg +3-6 l: llllll +3-5 j: jjgjft +10-11 b: xtlppqfbnkq +15-17 p: pppxpppfppppppppb +7-8 f: ffbmfffd +6-11 t: htgvbttnjzpkt +5-6 t: tvttwt +8-10 b: bbqbrtbrbb +6-10 x: xxspxkxmpxxxvrcxx +3-6 f: lgrxkfrfkfj +1-7 f: fffffftf +5-6 t: rcjtqtwvgsttc +12-13 k: kkmgwdjmgpkkgrkk +1-13 w: dwdwzlwxrtvhwwhmwj +3-13 n: nnwnnnnnnnfnnnnn +9-10 j: kbjjcsjtjn +17-18 v: vvvvvvvvvvvvvvvvvh +11-17 z: zzqkzzzzdzhzgzzzvzz +7-11 f: nrdftjqffff +3-8 t: tttttttctt +4-5 r: rrcrwrf +5-7 c: ccqccccccc +13-14 r: rrdrrrfrrrrrhrr +9-12 s: xjddslskrjpd +8-9 n: nnnpgnnbnnnn +6-10 j: wjjdjjjjjpjjjj +1-7 z: hzzzzzzzz +4-7 b: bbbzbbbxlb +4-13 t: tttqnttttkxtt +6-9 h: vhphhzhhshh +2-10 p: bpfwnncsmtppppsq +3-19 n: dnklnrnnnnfnnnngndn +5-15 n: nnnnknnnnnnnnnsnnnn +6-8 t: trttttwv +8-12 m: mtmmbkmxmjdjmmmtm +2-8 k: kjkkkkkkkk +6-8 n: xrnmndqn +13-16 n: nnnnnnnnnnnndnnnnnn +14-15 c: cswjctfcccrccxc +2-9 k: knkkkkkkj +5-12 r: rxrfwrdrcmdr +6-11 v: vxwsnvnxvgs +12-13 n: nnnnnnnnprnnmn +1-3 l: blbz +4-7 h: hhhbhhh +8-12 m: mqhrnmzmmmmmm +6-15 n: nnnnnpnnnbnnnnzn +3-6 q: lzjcxqpmjqsbqgxjql +6-7 q: qqqnqrq +5-7 q: qtlhqct +3-5 q: qlxmq +2-3 n: knnn +4-5 z: zzzzh +4-9 r: rrrwlprfrlrnpzrrmwt +14-15 j: fchdfjzmdrjxrxj +1-4 m: dmmm +2-4 x: wxkmpxn +5-11 r: rvblrrjkvrsbr +1-2 c: ntcmkz +14-16 h: hhhhhhhhhhfhhhhhhh +1-3 h: cnsvhm +4-5 w: wwwww +7-10 j: jjjjjjjjjsjjj +9-14 j: zjjjjjjjkjjjjwj +12-13 k: nqwkrcpkkkkkkk +3-5 k: vxkkj +6-7 j: pjjjtjpjjjw +2-3 j: jjsg +4-5 g: ggggcg +3-5 b: wbbnvxw +2-4 h: gwjhqj +3-4 l: ltlm +8-10 j: bjpdpvtjdj +1-7 v: vbfvvsvcvv +11-16 j: jbjhjjjjjjjjjjjc +6-13 b: bmswrnbdhbrfbmbb +1-4 x: xxxh +4-10 c: wjgcwbrkxk +11-13 v: sfbcphvzttvmzv +6-16 q: pqqqqqqqqqqqqqqq +10-12 w: wwwwwwwwwswww +2-9 b: fbwwwbrdp +3-4 v: vvnvvvvv +8-14 x: drwxxvqdgmpxmxfcxr +8-10 k: kkkkklkkkc +4-7 j: jcwrjjjfc +3-4 c: cczcgc +3-12 l: smllklclprdvlsl +1-2 j: fjqd +10-19 g: gggggggggqggggggggxg +3-5 m: fpmmmvb +2-3 c: ccmc +3-7 v: pvqktqh +1-3 c: ccfv +4-5 x: khxxj +3-4 g: ggbgf +1-9 x: xxhxxxxxx +5-6 f: zfffmfff +5-8 l: gmlqlkrl +7-10 c: ccccckcscsb +1-3 p: spppp +1-3 v: qmvvv +15-16 z: czhzzzzzpzzzzzzkzz +2-4 r: rrrr +3-13 k: kktkkgkkkkkkgkk +10-13 p: bpqpxpqqtprjn +6-7 j: jwnjjjxj +2-8 w: wmgwdwww +12-14 g: gggggggcgggggg +4-8 f: mdffklwtcj +2-7 j: jmjxjdxjrbrjjdjjrjwj +3-4 m: mmml +5-7 l: wllkqll +6-10 s: ssqcpssddslxncsbs +6-11 n: nnnvnznnnnwn +9-10 w: cbbqgrqglwgqskw +1-8 v: nvvzlhcvvvslv +1-3 t: tttttt +3-6 f: mftpff +1-11 t: pmjtttttttl +8-11 h: hhkmfhvhnwwhhhhhhh +4-6 k: kkkrkkkb +2-17 x: zzxxzvrsbmjxnxxxx +5-6 d: zdhxdldm +1-4 c: nmcc +2-4 j: njjjj +7-13 s: jjsbqrsddsclpvs +10-15 f: mbffrlpjtptgfff +10-13 d: dddddvddddddv +8-9 g: gxhgkggrgc +2-4 b: tbbcnkvp +9-11 g: ggggghgldgpggvg +4-5 m: mmmvm +2-5 d: ddfdp +8-11 r: rrrsrlcmltgrrbr +9-11 r: rrgrrrrxwrrr +3-11 g: zgggvgdggdsj +13-15 x: xxxxxxxvkxxxrxlbxx +13-16 b: bbbrbbpbbfcbqbbxbbb +7-10 x: jxlhxxxxxbx +1-12 p: plkprppjpppb +9-10 t: ttttttttft +1-5 q: qqqsqqjsqp +6-9 m: mzmmmlqmmgm +6-7 j: pbjjkjcj +8-9 b: bbbbbbbbxb +1-2 c: cflj +12-15 c: xskhcckcttmtmfc +5-6 p: pppppb +10-18 v: vjrplvzjxmjvvrvvfvd +3-5 x: hvfqxxqzqz +1-10 t: sttttttbttftttttttt +4-7 f: nrxknwf +3-9 l: fllltcllltlsjlc +10-16 x: cxxxxhxjrxxqjxxkxcx +10-14 m: mdmmmcmmmmmmmmmm +2-17 n: nmnnnnnnnnnnnnnnnn +7-11 s: dtpqdssfbbsrl +1-4 h: hhqh +2-7 j: jjrbbmjps +3-4 d: dhsddvflkqdvgd +6-7 m: gmmmpmr +2-9 j: jjjjjjjtpjjjjjjjjj +12-13 g: gggggggtggggz +16-17 p: ppppppppppppppppspp +6-8 w: wntlwwwhnwtgwhwjj +2-4 s: tntsjn +4-6 t: tgtgtt +6-7 f: qpffwwfv +3-5 k: zltkkgsvjhrbxwvkg +8-10 l: ljlwlgpllkklllflrb +3-5 q: qqbqqqs +4-5 f: zfffb +2-5 b: bbzhbbbb +4-5 q: sfhqpqtqbrbgdqgqw +13-14 k: kkkkdkkkkkgtkzpqkkk +4-9 p: bnpwptvkps +10-11 n: nnnnnnnnnnsnnn +12-14 d: ntpzdcqdpsrmddkcwgc +4-10 g: wgxxgsgggkchgggkg +2-7 q: qwbqccqlqmqqqsqcw +3-5 d: ddddddd +2-4 v: vwsvv +4-13 p: pppppppprppql +6-8 s: zcxssstnfr +8-9 f: zfffcqfff +10-11 m: qmbmmmmmpmx +1-3 j: qvjjkn +14-16 d: zfdmddxdrddvdcdc +5-10 w: rwwwwwwwwww +1-4 p: cmpp +2-3 f: dffff +4-8 n: nnnznznnn +1-4 t: bvrntkt +5-6 v: xjgvnvmgfwxvvv +2-4 w: tvwgtc +1-7 f: ffffffdfc +15-18 w: wwwwwwwwwwwwvwwwwww +1-2 t: jtct +2-3 k: cskdkkkl +3-19 q: qpfqqmqqqqqqqqqqqtqq +2-9 n: wnnjcngnkdnbnlrcbvns +1-14 d: vddfpndddfddddjhddd +1-2 m: bmmbwtwml +3-4 p: ppgrprpgrqb +2-3 m: mrmmm +5-6 l: zllllz +8-13 k: xkzptdzzkggkv +5-6 j: jjjjcj +4-5 b: bbcdfb +1-2 b: vbmbrbsf +8-9 q: lqhmjvdqgnxmb +2-4 n: snmrcnntn +11-15 r: rrsjrfrmqrlrqrz +2-3 l: dlblr +2-3 h: cthlxj +8-15 l: lllwlllllclfllbl +6-7 q: hqqqqqjq +13-14 f: ffffffffffffhf +2-4 v: dtxvztgnvffxlxfcdwf +5-11 h: hxhkhpfnhlchh +3-5 n: nnwcj +12-15 s: sssssssssmssssrcl +1-6 d: rdddddddd +14-15 b: bzbfnbbbbbbbbpxbb +4-8 w: jkxpzcnwhzsgmbkw +7-13 t: ttmlfbttdttgtpvktt +8-11 z: jdqfmwgltdztpzc +13-17 s: sssshsssssskslsxnss +9-10 t: tttttttttf +3-4 l: sllzl +1-2 s: ksxsxbwjn +12-17 l: dlvflhjmlgtldlllr +1-5 f: hfffffhf +5-12 f: gmklffbffztjfwswdg +18-19 z: zzzzzzzzzzzzzzzzzqz +1-5 c: cwccgcc +3-4 p: pspp +5-9 n: tknnnnsjwnsntng +6-7 x: xxxxxxm +6-10 g: szrpggtlwr +9-11 s: xgwsbcssxcs +8-9 t: dtttdtzrt +5-11 d: snddldcdhdd +11-13 m: fbkmsdvklzmtmkmmbjq +10-13 s: nqnsssmsvwrrs +3-4 w: hwnwk +5-11 h: ztkpgzhpfhh +6-7 w: wwwwwwww +3-4 z: zvzzczzlglv +13-14 l: llllllllllllll +12-13 x: xxxwxxxxxxxgx +3-4 p: mxkppr +2-3 d: ddbdt +3-5 l: zlplllphl +3-7 p: spmrbvp +4-5 b: bbbvn +16-17 l: zzxvmvxsgrprbclvl +4-7 h: hphwfshhrpgdmktsphhl +1-5 l: nllllll +4-5 r: rrrnr +5-9 k: bbkwgkklqkqhkk +4-5 t: sttnt +15-16 f: fffjffffffsdffwfsff +5-8 z: bzzzzjzzzv +5-7 f: qqzzffmfvb +3-10 m: zmmpmfcwdmfmvc +3-4 z: zlzzz +2-3 c: cjcsl +5-15 r: mrdznrsrctlrrqrflzm +8-11 g: ggggggggggdg +5-10 s: bnshsbvrthssmq +7-10 m: mmhmmmmmmmm +14-17 h: hhhhhhhhhhhnmkhhhhh +1-5 n: nnsnx +4-17 j: jmxjdkgbhjxflrmqjjdj +6-8 m: mmmmmmmb +3-5 p: ppppxrpp +3-8 t: jtjtttqttt +17-18 k: xklkkkkkgkfmrkkhkbhh +1-3 k: kkhk +13-14 j: jjjjjjjjbjjjgj +9-12 q: cmwwkzrkqsqqqmqhqb +3-8 s: sssfclpwhssfss +3-6 s: mshsfss +10-16 p: plftpppkpqppppppp +4-5 d: dddgdq +4-5 s: slsss +1-7 z: zzgxkzf +6-7 w: wwwwlwz +11-12 w: mqwwwwwwwwbzw +13-14 t: ttttttttttttlt +9-10 c: ccccccccvc +9-13 q: qmqqqqqqhqqqqq +1-7 z: rzzzzzmzzzzz +7-16 w: wwwwwwwwwwwwwwwcw +4-5 m: nkmrmxz +8-9 q: qqmqqcmqlqqqqw +10-15 x: ltnxqwwxxztmzhxxmnt +3-6 r: pkvpfprgwm +10-11 k: kkkkkkkkkkkk +3-4 c: ccfjs +1-6 n: nqvkzjn +9-12 k: qkhxrknkkzpk +8-10 x: xxxxxxxxddx +4-14 t: tttttttttttttbttq +12-13 h: hhhnhhhhhhhhd +2-6 x: bdwljxqxhkxjwpvdxk +3-4 w: kwfw +5-13 w: skrwgwwdwmcwv +1-3 m: mtmvsmc +5-7 v: gvbvvdt +7-8 s: ssshssspss +4-14 m: mmbmdbtmvhvmlc +4-9 g: ggsgnhhmgg +1-6 g: gsmfgjgzmkglzbgfjw +1-12 z: zzzzzzzzzzzdz +4-6 q: dbqjwnd +9-15 c: ccccccchccjcccc +1-7 l: fkllkmp +2-17 g: dggmgzhvphggcjgmtx +9-10 f: fffffffpfs +1-4 n: nnnw +11-12 l: llllllllllrl +9-10 p: ppppppppppp +5-6 p: pskgtx +7-8 q: qqqqqqjr +7-8 d: ddrdddkgddd +2-5 l: llllhl +4-6 h: hhbhlbhh +9-12 m: mmmmmmqmtmqgcx +10-13 f: fbfffjffffffjff +5-14 c: cvvrcmkhztsctfpf +1-2 k: fkkk +8-11 j: kjzchnjlrxjjljjljj +5-6 x: xxxxxq +6-11 r: zrkrrrznrfm +2-5 r: rdrrrr +12-16 c: cccccccccccccccvcccc +14-16 w: pwwfwwntkwwrjwcww +1-16 z: zzzpzmzmdzjzzzzvzzgs +6-8 j: mttjfgswgjwjjdjx +1-8 w: hwswwlwwxtgxbgkwp +7-8 h: hhhhbhnhb +3-4 n: cnzn +8-9 r: ltnkhrdsr +4-5 t: tttmtltptttttttltt +7-8 s: sssslsscszws +16-18 j: jjjljjxjjnvjjjjjjnj +3-4 s: psjpswct +5-7 b: kslrgbhcxmhbv +7-9 x: gxxxdxxxbxxx +1-5 d: lddddd +12-16 x: gsbzzgxnwsrmqxvx +10-12 m: mmrmmmmmmmmbmmmmmr +4-7 f: lfsfcnczbfh +9-11 r: rrrrrrrrrfzr +3-6 c: jfhnvcc +8-19 f: ffffffgfffffffffffj +2-6 x: lpfxdqws +1-4 q: xcvqnqvh +2-11 r: rrrrrrrrrrrcr +1-5 z: pvdczgkznqpxpnzrz +2-3 j: rzcjvmjb +5-6 w: wcwwwlblgplfwft +3-13 j: djjrjmwzrkzzn +10-11 p: hlsbzcpdqppww +9-10 f: fffffffffb +2-7 m: tvmjknlkdqlqmh +6-19 x: cqkrszrxppxxzrclxkx +1-11 m: zfmmjmmmlmmmmmdmm +3-4 t: fstwjtqqsdzbwrt +8-9 x: xxxxxxxxg +4-5 n: xnnnfnnnl +1-4 n: xxnngpfxl +5-6 m: tgsmmqm +10-11 l: lpvhlllrhcn +11-12 k: kkkkkkkkkfdkk +14-16 c: cccccccccccccbcc +13-14 f: ffffffffffffjff +10-11 w: hwhwqngbwmw +16-18 m: mmmmmmmmmmmmmmmrmm +8-12 d: bddddddrddddd +14-16 z: zzzzzzzzvzkvzzznzz +9-10 z: fzzzzzzzzbf +14-15 j: jjjjjjjjjjjjjqjj +8-11 b: qtfjvqgbpwb +6-9 d: ddddddddzddddd +5-7 c: rlqqctcr +5-6 m: mmkmmfmdwjd +6-7 n: nnnnnnz +11-12 s: sssssssssswpsss +12-15 r: rrrrrrrrvrgrrrk +2-3 b: bqbbb +7-9 c: ccccccdcc +15-17 s: sssssssspsdsssqsssss +2-7 g: bgggwrbggfc +4-5 n: ncdnb +11-12 x: xxxxvxxsxxrxxvx +4-17 c: crscfpdcrngngctxc +1-3 s: xsrsss +14-18 w: wzwwwwpxwwfwwlkwbl +2-8 w: tbjctwlwml +1-10 h: xhhfhhgjhhhhhwhz +13-15 c: cccccccccccclccq +1-14 j: hjfjjjzsjpjjjjjj +6-10 c: jccxcccbcc +5-6 n: nznnnxcnn +4-10 w: wwwbwwvfwwmwwws +9-10 s: krsgskgtvl +2-11 p: pppppcppppspp +12-14 c: ccccccccccccvcc +3-13 c: blcvjwrwzzwlmttsncg +3-9 w: wqwlqwqpdwc +12-15 v: gtwlqvxjkvvgvft +14-19 k: kkkkkkkkkkkkkkkkkknk +4-5 g: gggnx +3-4 r: rxxrr +13-14 h: hhhhhhphhhhhch +11-15 w: wwwwwwwwwwdwwwdw +16-17 l: jmphnlvdgmltcflxlm +1-4 q: qmqw +5-10 f: ffmbxfqffffbfff +2-14 b: bbbqjbxvdbbvbdx +18-19 p: ppppppppppppptpppnn +5-6 m: mmbmmkmm +3-8 d: ldkddkddmbcdwdrbx +11-12 s: shjssssssspgssssssss +2-4 d: fddqdd +6-11 f: ffffffffcszsrff +5-10 r: mrrrhrrrrr +2-17 n: nhtnxnnnnfnnnnnnnn +3-4 s: ssvs +5-6 t: ktgbft +7-10 m: mwmmmlmmmhp +10-11 c: cccccccccbc +1-3 t: rnttg +13-14 f: kjqrkfstrfngqf +12-15 g: gdgknggggqghgpd +1-13 t: ttttttgttttttjrttt +1-5 r: brrgrrrrr +4-7 c: cccnccccccp +11-12 n: nnnnnnnnnndl +9-11 j: jwjjjkjjjjfj +3-10 w: wdwgswwwwx +10-12 r: zzrrctnvrxfrrqrrjrrr +4-5 x: xxxhx +5-9 j: fqgwpjtjnt +7-9 l: lxllllllqllwllll +11-17 p: ptbzpvppswpppplpr +7-13 g: ggggggzgggggfgg +2-8 j: pbftjswjqzcp +5-6 z: zzzzzczzzzzzzzzzzzz +2-6 n: ntvnnnnnn +12-13 n: nndntnhknsnnnnnnqfnn +1-6 x: wtnxdw +2-4 f: fxxf +5-12 k: xcxrwkpfkkfkdk +3-4 z: lzzz +12-15 n: knnnnnnncnnnnnpnnnn +3-11 h: jdhfhhfmthh +9-10 k: kkkkkkhkskk +2-6 g: hhngvjgbkg +3-4 k: zkkz +12-19 r: rrrrrrrrrrpmrrrprrvr +2-9 d: dkddddddjdddd +1-4 c: zccc +7-12 d: dqbxtdxdgztddc +4-5 x: kxxxd +1-3 x: xjfkxvhvbq +5-9 w: dpqcpwcrwpwcqhlj +1-7 q: dkbtgkqxjhjzsqccn +4-10 c: cncccccccccc +7-13 b: bbmbqwbbbbbbbpnbb +9-10 b: bbbbbwbbbgx +7-14 b: bbbqjbcpbbjbvbbbqrxb +5-13 s: fspsqsshvhssssmrqss +11-15 v: vvvvvvvvvvvvvsjvhvdp +5-9 d: brwdshwddzvg +2-7 w: wwkfgkwtbvwx +6-9 l: llllwnlllll +4-7 h: hchhhtpr +1-4 n: npgnn +3-4 k: kvkkkkjkkxkgkk +1-13 m: xmkkhmwddbtkm +6-7 x: xxxxxxr +15-19 m: mmmmnmmmmmmmkmbmmmd +14-15 z: zzzzzzzzznzzzhzz +11-13 h: sfhxhlhtnnkvdkhm +9-10 z: dzzzvzzzztmhczbzx +5-7 v: vvvvwvv +5-7 z: zrgzxzzfdz +1-3 n: nvlm +4-7 x: xkvxxjt +4-10 m: mfwzzmnqfsdkxzmmmm +1-15 x: xxxxxxxxxxxxxxt +5-7 n: nnnnnnm +11-12 z: xknzzzwddzxxzzzzzzhc +3-4 f: fzflfjf +4-6 g: ggkgrxg +1-2 n: sncpt +4-18 z: xvrsrxzzzzlzzznzzz +5-7 j: jbhfjcrpkgjhp +6-7 g: gggggsh +8-9 n: nnnzntnqpfnnpc +8-9 k: kkkkkkkxsk +6-11 n: nnhntnmhnnms +3-5 q: qzqqqqhlcbfdqq +6-9 r: rrrrrrrrvdjrrrr +3-7 r: rrrrqhm +6-9 t: xmdtvstttjtt +3-5 l: gnsnlp +2-6 x: hxjxjd +2-6 t: tttttp +7-8 l: vdtrllllrmlwllcplgb +10-11 t: ttttttztmwtt +3-4 d: ddgd +9-11 j: jjjjtnjjqjcjj +6-7 n: nnnnlcwbn +4-6 g: ngdsggg +7-9 q: hnxrvqjqqr +3-5 l: fltllw +3-11 g: gghggggggggg +7-17 w: wwwwwwwvwpwwwmwtgw +2-19 n: nhnnnnnnnnnnnnnnnnn +1-2 n: xnmr +4-6 x: xtxxxpxxxx +10-13 z: zbzzzpjrwzdzxszzzz +9-19 b: bbbbbbbbbbbbbbbbbvbb +9-10 w: wwlwzwwwvr +5-9 p: pnkpdppppppkpwzpp +15-17 j: jjvjjvjjjjjjjjljwcj +3-4 t: tttkt +1-5 j: jvjtq +2-11 r: rrrrrrrrrrwr +1-4 x: xqpzxwcslbj +3-4 b: bpbp +11-13 w: wwwwhwwwwwnwl +2-4 f: nfnjtfkbsxvm +6-7 v: vvvvvvs +1-4 t: xwtxxmgfwpkqd +5-6 h: hgjhrhhhh +2-4 p: psppp +10-14 j: pqjjjsjjjbcbjjjjj +3-7 d: ddbjddgzdd +6-7 l: llsllbl +1-13 p: pppppmpppppppppppcpp +1-3 r: rbdzrjsrd +11-14 x: xxxxxcxxqxxxxs +11-12 c: ccccwccczccccc +2-12 g: spwsxfgdrqngkqgdb +1-3 h: dhrhh +1-7 f: tfffffff +15-16 s: sssssssssssssvssz +12-13 q: qqzqqqqqqqqvq +4-5 g: cgxgk +3-8 n: nnnnnnnnnnnnn +1-3 r: rrkr +14-15 g: sgtgggggggggggxgr +2-5 s: vhcts +2-4 x: xdbvvrnxxhnzsl +8-11 p: ppwpppclpvlp +7-11 b: bblbbkbbbbmxfqgxgk +5-6 d: dddldffx +5-6 z: zzzzzwz +11-15 q: hqrqbzbhnhdqjfqdvg +3-16 b: btgbbbbhzbbbbbjb +4-5 f: ffvkf +6-10 q: qqqqxqqdvlqq +12-15 g: gggxsgsnwqxldmg +8-12 d: ddddddjpdddh +1-2 p: pphgjjm +9-11 d: ddddddmdfddd +18-19 z: zzzzzzzzzzzzzzzzzmz +8-14 r: rrrrrrrtrkrrrq +4-5 t: jhtrt +3-6 h: bjhwkpdjqbnng +4-5 m: mmmmbm +2-4 t: dqttgszbrwpcdr +5-7 q: dfxmqxxqtdfqxqq +3-5 k: kkkcmk +7-10 t: tttttttttn +7-14 m: mmhmbmkmmvrtmxgxwmm +10-11 v: vvvvvzvvcxvvv +5-6 s: lssssbrssl +8-15 h: hhbhhhhhwhrhhhqh +18-19 q: qqqqkqqqqqqqqqqqqtq +10-12 p: xpprjzzlpqspsnpb +5-6 t: ttttgt +4-12 s: csvwsslsshgkbsrds +12-17 z: zzzzzjfzzzzzzzzzzzz +4-5 f: fnktwj +3-6 h: hphdhvh +16-19 m: mmmmmmmmmmmmmmmnmmmm +5-8 m: msmjtplmmtqbm +6-9 q: gqqcqqqrq +1-10 g: gvgfsqggph +10-11 l: nlllpllljql +1-4 q: qqqx +2-4 q: qbwqwpqq +3-5 s: scsmjtszkscsds +2-5 t: txttfttt +1-2 s: swsqspmz +2-4 f: vffw +11-16 r: rrrrrrrrrrjrrrrq +2-13 r: rlxpzrftnrkhrvlzrp +4-7 g: lggfgsggggggggggg +4-5 w: wwblw +2-5 t: tbgtg +6-7 n: jvzmhnmnphhx +1-8 m: cmmhmlmmm +10-14 x: wtxtkxxjpxxxxr +3-5 h: hmchhfhk +5-8 h: qgfkhktmhhhmbw +10-11 k: kkkkkkkkkkh +5-6 g: ghzggxgsgpksg +3-4 w: mwwv +3-7 p: zppsxpnbj +1-2 d: qtdd +9-10 h: rhdhlhhhwhhtdhzxhp +1-6 v: lvtpvvnb +2-6 q: qqqlqm +4-8 j: jjfjjvjjxjj +13-14 x: xhvqxxxxxxhxxq +10-13 k: kclwxblmncnbkkdhrhr +1-3 j: jjpj +3-4 b: sbmxhbbt +2-3 d: mjscddjrh +2-6 x: xxxgxqxxxxzxrxx +19-20 h: hhshhhhhmshhhhhhhhhq +12-15 s: scbssrsslnsskfbs +3-4 p: jpmp +11-19 p: pppptpppcthpppppppp +1-5 w: lwwvw +3-4 d: xzfddddpdddzdjxcdd +3-8 f: fspmqqkfjtfrz +9-12 c: cccccccccccr +15-16 w: wwwwwwwwwwwwpwlg +2-3 v: vzvb +10-18 t: txttttmtmtrtntttfktt +3-12 h: mwbdpslghxxhhh +2-9 l: lcllllllxllllllll +9-10 r: rrrrrrjrtrrr +2-9 m: mmmbmmmmmmmm +7-13 t: ttttttttttwtz +7-13 b: bzbbbbqdxbqbb +5-7 d: ddhdddmd +4-5 b: bqbdkbbb +1-3 k: wkkkk +4-6 d: dddddf +2-7 j: tmnjptjtrvx +5-7 z: qzlzzzvzm +4-5 h: hhhhhf +3-14 s: zsrkrsssmsssshsssss +7-8 k: bkkkgkkxk +8-9 x: xxxxxxxtxm +7-9 j: jmjjjjljjjjb +10-11 n: xnnkrqnfnjnnnpncnn +3-6 c: cxcdlhv +1-2 q: qdlmfhgtgrnqhmvqmkhm +6-7 t: tttttttt +2-4 j: xjvzcjcftgvfqg +5-7 n: srnxnjjgdnnnnqrwt +2-3 z: vhzzvk +6-13 d: nlbwzrpsrfvwddcz +1-3 s: ssfs +10-13 n: nnnnnnnnnmnnnnnnn +6-8 g: lggggnggx +7-10 j: jjjjjjqjjjj +2-10 c: fccbgjccvzwqczcvcc +3-4 p: wqws +1-6 w: wqbjbnrp +5-9 v: vvvvvvvvhvvv +13-16 n: nnnnnnnnnnnntnnn +5-7 h: qzjhhhp +14-15 c: ccccccccccccclcc +11-13 g: tkthwlwggncggxmjfk +2-11 v: vndvvvvvvvvv +10-11 p: ppppppppppt +1-11 c: ccccccccccdc +9-10 b: bbbfbpbbtbb +5-10 r: rrsrrrckhp +2-16 v: vvbktgjvhvvkmfbvccwc +6-10 v: nrvxrvcvvvktrvvvl +10-17 d: ddddddqdhdddddddvd +5-7 f: fqkxhfffghfc +1-13 z: zkzwcggpsppzzxwcbbp +2-4 d: hkvdzhlpbqdnvrjsc +9-11 x: zxxxxxxxsxx +14-17 q: qqqqqqlqqqvqqgtqq +5-12 q: qqqqqqqqqqqrqqqqq +10-13 w: wxwbnbkwgwxwhwwwln +5-16 c: xzvscccccjcccchhc +2-3 v: vgmvvvvvvvvv +7-9 j: mjjjjpjjdjjjb +6-9 q: gqqqqqqqq +10-12 p: pcpxppppprpppp +1-6 s: zsssss +1-3 g: mhggg +2-7 g: gsggsgnvggggqggvlgrc +1-6 d: rddddddd +1-3 n: nntnknnr +8-9 t: tttltttttt +5-6 f: jfzqfljhkwdn +12-14 j: jljjjjvjjjjjjcj +9-10 q: qqqqqqqqqwqq +2-11 h: hhhhhhmhhhqhphhh +4-9 z: cldzzfxzblb +3-4 l: lvlm +3-4 m: mmrmm +15-18 m: mmmmmmvdmmmmmdmmmsmm +4-5 f: wffzff +10-16 b: bbbtmbblpbbbbbmmbv +13-14 d: dpdmjrgdqrdwwd +6-7 m: mmmmmjm +12-19 g: gggggzxggggrgggglgvv +10-15 p: ppppspbpvpkpcpqppp +4-10 m: mmmmzmnmpct +11-12 c: chcccpcccccdcccpd +3-5 f: ffnzqjzh +1-6 p: cpjpppp +7-14 p: ppppnpqpwnrtmbjjppm +7-8 w: wwwwwwtw +3-4 d: ddds +3-4 r: vrxdtlt +2-7 w: wcwvwwqw +5-12 b: bbbbbbbbbbbhb +1-5 t: tlvktt +6-7 p: mprngps +8-12 x: xxrbnxxjhxxxxlx +1-3 x: xvqx +5-7 v: vvvvqjvvvvsg +2-6 w: fwwjwz +16-20 q: qrqqbqnqqfqjhqfqqqqh +3-6 j: jhjjjfjsjk +4-9 k: rkgpgskkz +2-4 z: gzdz +6-8 t: tttttsttdtttt +11-12 p: ppppppppppppp +4-6 x: mzqcfxct +16-19 d: qjdlfdccdbxngddnkgn +2-3 f: rrcvqfs +13-16 z: zzqzzjzzfnttznxzzzz +16-17 w: rbngvbwpgwgzkwswp +1-9 k: klkkkkpkp +3-4 f: fffxffffff +1-2 l: lhpl +1-4 w: vznmj +2-3 j: jdjmpjd +17-20 v: vvvvvvvvvvfvvvvvvrvx +3-7 w: wnzwwswwwwj +3-8 m: mmnmmmmmmm +3-4 l: llmll +9-11 r: rrrfrrrdqrwrr +9-10 w: wwwwwzwwhw +6-10 t: pttwtbxqgttttntktjt +1-3 j: jpngpm +1-9 g: gggggggggg +4-5 b: gbbtb +2-6 q: qqblqdrnmcnhqvvpvkq +6-7 w: zwwwwjw +2-8 w: rpbbwwwlqzhl +11-13 b: bbqbbbbbbbbbb +7-10 v: vvvvfvvvvv +6-17 t: ttttttttttttttttwt +2-3 f: fbff +8-13 l: qlllzllmllgllmlcl +3-4 n: nnnfnqd +9-12 z: lzzzlzzzzffb +3-11 p: bhlpnccgcfp +1-3 s: stccsf +10-18 p: pdgpphscppdlpppvsh +3-6 j: jjjjjq +2-3 s: dslwlsvljc +3-7 g: sgggtdgwkdhspgnxkglv +12-13 h: vrgnfshfssvhh +12-13 m: mmmmmmmmmmmbgm +12-16 d: djddvdqpdddddjlt +3-4 k: kfkmkpk +6-13 s: ksphskxpdswsssbbnwwt +6-18 x: xxsvxndxxxxfvkxxbxs +7-8 d: dxbdddddddd +6-7 q: qqkqdcqjfdqqbbqp +4-5 k: vkkbkzqpk +4-9 l: llbhllllldl +14-17 d: ddddhdhddddddxdddd +3-5 r: htlfbsgmvz +2-4 h: hthhh +4-7 l: xlzllbqkdwqsllfsw +17-18 n: wnnrnnnnngnnnnnnqnfn +1-3 j: vlwkv +1-2 g: bggz +10-11 x: ddsxjxxtnxjpcxxxxxv +4-5 g: hggkg +5-7 t: khtnzct +10-15 g: ggkggsggcgggggqggwgg +9-11 s: ssssbwjhssj +1-8 b: gxvbllbjqk +2-3 w: jgwqhrw +7-8 j: wxtqdvjpbcfzxsjlpmsj +9-16 b: bcpbcbbbbbjmbpwbbj +2-5 t: tpttttt +2-3 z: pzzz +3-10 j: jjpjjrjjjjjjw +5-8 t: tttttttxt +5-15 r: rrnrrrrrrrrrrrkr +8-9 j: hdjwgbjmj +3-14 c: jcccwcccccrckccch +11-12 n: jvzktxgpcmnjglwljrn +9-13 k: vqsgdcksxtxhks +3-5 c: zdccczpwlxt +3-5 r: wxgkrqrsgl +7-8 s: kspsssksswssj +3-7 j: djjjhbrkhtncxjvf +11-12 x: xxxxxxxxxxxz +11-12 t: ttttttttttht +8-11 v: ptvvvsvtvrvvwvxvtfg +9-13 d: nhjddddvlbkdcdntdf +3-6 w: gnwwjqwzqwm +3-5 s: tsssc +3-7 k: kkkzkpmmll +13-15 k: kgkkkkkkhkkktkf +5-8 t: ktttrttnt +1-4 z: nzzzzzz +2-4 k: lkkc +2-3 z: szjh +19-20 d: dddpcddkddckdddbmdld +3-9 q: xqqqpqqqwlqqqqq +14-17 s: ssspkssssssssssslss +17-19 c: ccccccccjcczccccxccc +4-13 h: qtrhflbfmkfchjmfzph +10-18 m: nmmmmmmmmmmmmmmmxd +5-11 n: dnnnfsnnkznbgnjn +6-11 c: cccccvccccc +7-9 d: dddddrxdzldv +2-4 z: zbzz +1-6 j: njjjjjjpjj +3-5 p: prpww +3-16 c: tqjdhbgxvxcxwbvcn +4-5 c: vclfc +3-18 x: xxrxxxtxxxxxxxxxxtxx +2-4 g: gvgggg +6-12 j: cjjpjjjjlhpt +3-4 w: pfwq +5-14 v: vsqqvlrmqbbrlp +2-12 l: rlblqwmphxzpsp +2-8 h: hhqqvhhphhhqddhh +7-9 f: dnfvhwwffk +4-5 p: ppppcd +8-14 t: ttttdtqhttttftttt +13-14 f: fffffffffffffff +1-6 s: jrtwjslzwgkt +4-6 c: jcwzhcscc +10-14 x: llxxxxxxvnxsmx +1-2 h: hhhhv +2-4 d: mvdclzddj +16-17 t: tttttttttttttttmt +2-3 l: jklzlmzrppdpzt +5-6 g: rvfgnggjgk diff --git a/2020/02/part1.hs b/2020/02/part1.hs new file mode 100755 index 0000000..9da58d8 --- /dev/null +++ b/2020/02/part1.hs @@ -0,0 +1,35 @@ +#!/usr/bin/env runghc + +import Data.Char + +data PasswordEntry = PasswordEntry { min :: Int, max :: Int, character :: Char, password :: String } + deriving (Show) + +-- This could be a lot better... +instance Read PasswordEntry where + readsPrec _ input = + let (min', rest) = span isDigit input + min = read min' :: Int + (_, rest') = splitAt 1 rest + (max', rest'') = span isDigit rest' + max = read max' :: Int + (_:char:_:_:password) = rest'' + in + [(PasswordEntry min max char password, "")] + + +main = interact solve + +solve = show . length . filter (isValidPasswordEntry . readPasswordEntry) . lines + +readPasswordEntry :: String -> PasswordEntry +readPasswordEntry = read + +isValidPasswordEntry (PasswordEntry min max char pass) = + let countedElem = countElem char pass + in min <= countedElem && max >= countedElem + +countElem _ [] = 0 +countElem a (x:xs) + | a == x = 1 + countElem a xs +countElem a (_:xs) = countElem a xs diff --git a/2020/README.md b/2020/README.md index 157bc03..a267682 100644 --- a/2020/README.md +++ b/2020/README.md @@ -12,13 +12,14 @@ asdf install ## Table of Contents -| S | M | T | W | T | F | S | +| S | M | T | W | T | F | S | | :-: | :-: | :-: | :-: | :-: | :-: | :-: | -| | | [1] | 2 | 3 | 4 | 5 | -| 6 | 7 | 8 | 9 | 10 | 11 | 12 | +| | | [1] | [2] | 3 | 4 | 5 | +| 6 | 7 | 8 | 9 | 10 | 11 | 12 | | 13 | 14 | 15 | 16 | 17 | 18 | 19 | | 21 | 22 | 23 | 24 | 25 | | | [asdf]: https://asdf-vm.com/#/ [haskell]: https://www.haskell.org [1]: ./01 +[2]: ./02