From bb18d9a8d07ff32c1c9888f5eaeae4bb2fd64d57 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Fri, 1 Dec 2023 10:31:20 -0500 Subject: [PATCH] 2023 day1 --- 2023/full/day01.txt | 1000 ++++++++++++++++++++++++++++++++++ 2023/full/day02.txt | 0 2023/full/day03.txt | 0 2023/full/day04.txt | 0 2023/full/day05.txt | 0 2023/full/day06.txt | 0 2023/full/day07.txt | 0 2023/full/day08.txt | 0 2023/full/day09.txt | 0 2023/full/day10.txt | 0 2023/full/day11.txt | 0 2023/full/day12.txt | 0 2023/full/day13.txt | 0 2023/full/day14.txt | 0 2023/full/day15.txt | 0 2023/full/day16.txt | 0 2023/full/day17.txt | 0 2023/full/day18.txt | 0 2023/full/day19.txt | 0 2023/full/day20.txt | 0 2023/justfile | 12 + 2023/python/_sample.py | 27 + 2023/python/anim.py | 45 ++ 2023/python/day01.py | 66 +++ 2023/python/matrix.py | 425 +++++++++++++++ 2023/python/shared.py | 161 ++++++ 2023/samples/day01.part1.txt | 4 + 2023/samples/day01.txt | 7 + 2023/samples/day02.txt | 0 2023/samples/day03.txt | 0 2023/samples/day04.txt | 0 2023/samples/day05.txt | 0 2023/samples/day06.txt | 0 2023/samples/day07.txt | 0 2023/samples/day08.txt | 0 2023/samples/day09.txt | 0 2023/samples/day10.txt | 0 2023/samples/day11.txt | 0 2023/samples/day12.txt | 0 2023/samples/day13.txt | 0 2023/samples/day14.txt | 0 2023/samples/day15.txt | 0 2023/samples/day16.txt | 0 2023/samples/day17.txt | 0 2023/samples/day18.txt | 0 2023/samples/day19.txt | 0 2023/samples/day20.txt | 0 47 files changed, 1747 insertions(+) create mode 100644 2023/full/day01.txt create mode 100644 2023/full/day02.txt create mode 100644 2023/full/day03.txt create mode 100644 2023/full/day04.txt create mode 100644 2023/full/day05.txt create mode 100644 2023/full/day06.txt create mode 100644 2023/full/day07.txt create mode 100644 2023/full/day08.txt create mode 100644 2023/full/day09.txt create mode 100644 2023/full/day10.txt create mode 100644 2023/full/day11.txt create mode 100644 2023/full/day12.txt create mode 100644 2023/full/day13.txt create mode 100644 2023/full/day14.txt create mode 100644 2023/full/day15.txt create mode 100644 2023/full/day16.txt create mode 100644 2023/full/day17.txt create mode 100644 2023/full/day18.txt create mode 100644 2023/full/day19.txt create mode 100644 2023/full/day20.txt create mode 100644 2023/justfile create mode 100644 2023/python/_sample.py create mode 100644 2023/python/anim.py create mode 100644 2023/python/day01.py create mode 100644 2023/python/matrix.py create mode 100644 2023/python/shared.py create mode 100644 2023/samples/day01.part1.txt create mode 100644 2023/samples/day01.txt create mode 100644 2023/samples/day02.txt create mode 100644 2023/samples/day03.txt create mode 100644 2023/samples/day04.txt create mode 100644 2023/samples/day05.txt create mode 100644 2023/samples/day06.txt create mode 100644 2023/samples/day07.txt create mode 100644 2023/samples/day08.txt create mode 100644 2023/samples/day09.txt create mode 100644 2023/samples/day10.txt create mode 100644 2023/samples/day11.txt create mode 100644 2023/samples/day12.txt create mode 100644 2023/samples/day13.txt create mode 100644 2023/samples/day14.txt create mode 100644 2023/samples/day15.txt create mode 100644 2023/samples/day16.txt create mode 100644 2023/samples/day17.txt create mode 100644 2023/samples/day18.txt create mode 100644 2023/samples/day19.txt create mode 100644 2023/samples/day20.txt diff --git a/2023/full/day01.txt b/2023/full/day01.txt new file mode 100644 index 0000000..fba06e7 --- /dev/null +++ b/2023/full/day01.txt @@ -0,0 +1,1000 @@ +9cbncbxclbvkmfzdnldc +jjn1drdffhs +3six7 +38rgtnqqxtc +rxszdkkv3j8kjhbm +54nzzddht8ninelrkkseightseven6 +6fourmnvkgnthjtnjqkr +nineninezsstmkone4sjnlbldcrj4eight +3rdnfkvrx4twoqgeightqkgmn +6mlhponeglrzrvbsseven +five8spgxz8 +3three2dfourfour58 +9q +two45 +five8mpkpdfiveeightfourseven +93threefive3three92 +6jdzeightnineone1sclhzrnrjxfive +6nseven16lbztpbbzthree8five +eight6mntljvbfrmftsffchsix4 +4twosixvnhjl +8d +eightsevenvqvzlqxkbm6rqhsgqpnine7twonex +seven96 +ck8tv6 +2mcddqpnbxssmrc6 +zsfbkrjjqpbbone6six2 +fourone8hfrkxrr +7ninetphdpcx +9gcn9six4mfnjgtcdc +6onevsevenseven4three +ldssggpknine7 +twolltbfkhltwo892jngx +rsh1five3ninefourmfk +xtrh534nqxr +ggllvfjthreefcckbninekspmf6bnpkvt2 +kng16 +kqgthcleightsixeight96nine69 +nchcdqbsxmeighttwo65onevtqrznxmnl +chphzzqb6threeqhspbgkrn6 +8threevbqxl4 +99eight2hgdvcqdqxsnmkxctskvxxvqxjt +9qb95oneightsf +tfmpcthbdbnzhldnbj96 +9mzbn +twoseven9rmssixbvbjpsbjbh3two +7fcmfjjrtz5six4 +hpspsgtfxvxtmdsqcninelcjhfb2mhffpvxkdxdlvkqxnine +fivexrhxhtfivesevenone3d +jvc6twofourbgfgrthree9fourmhz +8xfvjdqlgfrlhzds4 +5271ninexfthree +fbm1jd3onenine +2jm7fchdklthreedzfg +6lgrrzfkj +eight6sixthree +eightsixzng8dxxnfbqdjkjt1two +fivesix92j +1kfrjjq +tjjthblvjfspbcshfivesix5fivesixf +nrlx5vqzcfive +doneightthtpmjlzhgpxdc18229twofive +6shtlqlbsxnine7snthree +oneonengtbjmlq4 +sixhxvzpshrhbbk3qdxrbq +23onezbvbrlnseven239 +one883mztbhfvqqq3srfptz +zxlglzxgkltc8four6kzmqf5eightstzlqcvxt +3four452jclt +sixmone3phrxxdninetwosix +3nine39 +578nine4 +442ffhxfrxb +shnnn3nqcgfbgpzzfrtchbseven5dk3 +ninenine5xrxrhcr +ninefourdlckvqzz6oneseven +fivetwoqcnqhbs9 +2sevenbgp8one +twohqbp7fnndbjpn +2nctn1pbbxmns +46fourhjppdlkr +cbfour3seven7dctlone +sevenjxbbplfour488trzv +5qqfb9twooneonethree +7zzlgxrfmlpxrbbnjt7five5mxhd4 +99vdnnzcdsqxgbonefoursevenjjjgc1 +4threeeighttkqdxnkrgblvnine5 +sevendtlm5onetwo +threeonejvxqb15nnjndprnn5cdxb9 +hkr1mtcmqqqsixxbfjnlqqlb +six2five3jkknzf5 +9xgkspdhrfivesix15zj +nsztwo4jxfzxbtrsjjnj8 +1twofive2sixqxxrjpgbdfive +41sixgmgxzdseveneightmnmxj3 +8qrvxvfourseven1 +lms268eight +7ninethreeksjz +qeightwobrfvcssthreeeight3167 +ninetwoone532fqhggszllnfcmfs6 +838lcrhzs2 +ninedjpteighthqrgvklln3cxbt +8lfxxeightone4526six +1lmvvbl +fvkxpcjm7tzzgkxfqoneeightone7nbxzskngd5 +twompjtfbt2 +twoeight4six +zmpml5six54fourfour +pndklmzmsseven9pncxgjrnine1three7pkjvv +88kggbsqnfjngqffkbp5fivetwo5 +1xrvkpqvspt +1eightxhpd5bsctj3three +twothreexjvsxklsxeight4twofour +tvqsngkbl7eightzxhxjmrhgs +5zkxqxx +7eightfour +3pjsrdp +fivermk75ninetghvdrltz +prfthbhsftpmfcn7ronesix +three9pvxmhkscqv +sixninetqhj5two +nsoneight3eight +nineqdprvhtqb4fbone98nineeight +ktfgnssfourdqktfflninephpntvmmm139 +qvxfzrdnineonenkpgxnnmqpsxrlcvjq5onehx +cq57sixeightwosvx +225vntfqdzqjgmtkdgbxrsr6three +56981stx6xdjkhnvgq +xksevendzeight2sixone +863 +onethreetwofive5sevenfdmrmczlqs +28qcdzgrbdkh +6two43four +fourseven4 +1jgone +qmpsfscxxtsix872 +6sixthreeeight +1bzxjhv2x +onecs5one7five +vr4phpdtmk3fivebtltwom +4onefourqqrpvxn1two +3sixsixjkfssevennpjfzhhsg1eightgj +seven1eightsevennspvrr9 +5fiveseven7ninepkzzj +xkjpxsqsfiveeightjgv2onelhdqjd2 +sone7rhbtvlttsix +vrc6five6 +twoseven7 +onetwo9onehndznine +5six6sixr +vfiveeight6hdxnpfktttstnvhjks46 +fiveninefour8zpptwoonefjzvmnhnvq +five53 +seventpfztfccgm8bxjsjxgmz +eighttwo4tktgpbj +6426 +jjkfournqbdqkddhlninekvd56bdshtbvn +onefive1onehkhsix +7sevenm9twofourqp +26sevenseven3twonelq +46threethree9seven +9pnzsix648kgngnpxttzlqlmnine +seven7onenine +two3mtklsvrrbthtxsrgrtwo +gkpfrq4vfddfqxzppmvthree733 +fq2qbmone +threecvone7eightsevenxnmfbtp +fivetmbnqlchhtqmbcsssvxjzvlxdvznlbfive7 +fvqzlcp5 +qhgjmzntonefnlxfqqrxx5three7twofr +rczhlkcqpfkgcjmcggztjlqsgxmdxstwo88bdxmqjvlfl +npqxcdnhltbjmpjvdvfvvthreennsnbfljq2 +four9gl +gjrf94three14 +5xrpnzlneightsevenlkkltrpsqgzbzffpjhrkc +twozmxqcsgkvjtkshttglxcx234xtzhht5 +fournine3rkxhdvjlzfour +4onesnfive1sixeightwof +threeone6sjnfive +4ninefournrphscbjjc +6xsvn6twofourseven4four +khbqhgqpph5krdsrs35kfbnqdbb6 +7kdn5 +4scmksvgl8twoltonetwofivejl +mmmkthreedmflzpmxqtccfz7 +lbkdqjfcf58hpdtgjnnvhsixfive +chfbqldb52qkpzlkx +98gbxklnbcb +ghqrqplpone2ljzseven9 +fxqfour2njrxrz79 +rcbcmlvqc57btvhphxqbxvxxkjtlcvjffgxsdtjfb +crgvfkklfivesixsevenngm52jl +8rhvh5gdvx24 +qcnlc62 +pmcdbsvzgtqgczdvzln6 +fivernine29 +skslcfqkgk47four +9twonine5sevenone +ccltdxdfksnninekpzccsvtgrtseighteight9pgvlbkvs +1nine7dqxdgknlz75 +fourninebbpthvqntf6759foursix +qsvpn4mvhxgmzsevenpnkmtzrg +82fqxx6oneg +sixhnrk34 +nine5five6dkqxmnc +qhdzhhqfbfjnfmglvxctkjm59 +1threeeightbchlm +1drjnqoneninennhqt +56six6two76bs +7onefoursixhkhpdns +4threectphcxfmmksdcsvhgfx +5jsqbninelphjdmsnjl9eightql +5vkkmjkrxpntmgfkfxmg4 +6sjxrtfnjkthree +pmeight418 +vgldhpczvgr2twofour784 +5ndkknqfjjxfiveddfiveb +five1tmv +four37fourninethree34 +rcnvxqrsevenjttxd9fiverqzblpnrcjhbc4 +tdhvhhjxbbmjnls1vn8six +two4three9 +2ckvlpznbqbqblqbr +6nineseven8zfqfptcjxtfmmkqpj +2jdxnqttrjvhmbbxqqmeight +zloneightjzsxtsxhbgtwokdfour2pqmfkkqksxlfv +8sixfive3 +qxgzh3gdjmdqlpdnfgdxvbblpnqtsevenseveneighthvmqqdmr +8jjmbqnfive3bbxdzctxxn9five +fivethree38four +pdzbkmcvhbvfivexv5five5hzvvg4 +4eightkmsrlqsfcnmzvprdf4rcxxqtvpqcfjfptmk +twortrlbqqkrnqgxhgseven5 +8sevenltzbjsfjxdkdjncm +1nineqqbjsoneeightmzvfn +threeeightsevenfour3jhkcthree +nine265sixthree +nnmbqhf6three +4one5fivefivehbfktxgrdkdrgp +twothreetwoseventwo8 +bkggrdbngtjfmhone6fmvfzpjldzb +bpbg4tjqnine56zklbtkzlrs3 +4twokmxgqbgqgsseven8oneseven +hvdv74ninej +dfknvxfmczqrgdbqsph823 +3twoeightnine +foursixeightbfhlczrpjfxfive7two +fcpkrvmtzxkrfsmqcbzeight7gfourfbkthreeoneightvm +four18vgkmj2gxmtxsbnvxthree +415threecshnzmmx +sevenseven44lkfourgmqtrs +jnzsqsgznvcnjjfbblkteight8 +497three5eight8d +88onethreexzsbgprp1 +eightszseven9htqlxb +1lqqgzdrxt4qlqklftlsqzm +rqbjqpfhzfeight6oneonelllcmbrdxqhmttptg +fpqxqfourthreefqgdsmhjfk2rmb4 +qnshr9threeonefour +xshsbkqxpltjsd2fivexvtrmnlpvtwo +446 +nine2pvn12five7 +fourfourninemvfvztpkbb9nine +3fhtlpone7965four +qkpdgtrfprttrzc69 +1mfsltcsxvlcxfzdh3 +fgjfltjcsnps8three +tbeightdsdtzmncv5pdcsk +rsjvlhxtn7six +7mdtl +four3three6sgxdtdmtnfive3 +3eightninenineeightlxtqtspmklrxbknftrbh +onenine92sixrnine6tggjndsrfd +oneqdfhrfzlteighttftvfcrmmzz43lbmlbg +35bthreernjskthzrs1two +threesixeight7rjpcxnzmzfgngjpkk6eight +six9ninerxfnldpsevenone1threenine +5sixhjzkknthreenxklxbvgxfouroneseven +1zkx93two9sixseven8 +sixtwocdnqdn2vdbnblzlvffmrninetzdtdpjjsrsix +twoeighteight437nrscj +six31vtcphkpltgbcprdhvdfivefoureightwonvh +8pz +hzrggpcmpnqzzgnxjfqrlllgnqks496five +7glkjtgbsnqhnplzcp9rllkkznffnznngthree4seven +one7fivetwo45 +4nxzxtnhb5foureighttwo +threeone56lgzgdklhtwo +rjnmxbflvn5oneightpj +fs7tpvvf +fhfkcx1hnzzjjh +6onexqrfvldeightfourkcvpngj +1threeeightxxcnjfl3zbxfgmfsx +9327six +three5p86sixcxdsjjvn9eight +four1cfrxsdgnjtwo +rxjmtgsixone87 +49sevennbgqf +sixone42 +three3jblhchr +hlroneight3hsjhkl +sgtrvtcq22 +8seven985 +qrhnjnkstwo4fourthree +8phnkkdrghbmtql +two9sixncgqpsseventhreefourthree +one3six3 +1nine4rtvxxgddzhf2 +2cfp84 +khgkvntthree2 +vsznj15ninehhlfiveone +mmrxqjbjmrtwo7 +oneone7ninekmzgq +eightone84lzktckgrbkzjzkqqxlgqn +btzdblrrpfxljsix69 +82sixseven +two5nineseveneight2eighttlmvfkf +vlbnccpl1 +four5gsbz7 +418ncqrk651 +bkbbncm9eight6eightnine +3sksvljxpkz4vcxsdnztfxeight8 +fivecfrlnh51glx2dsjqseven +hnflgpth64threefour +mjxthlr1six4tdplzrnhklnz +ddrkrnssxtlkhbrjvkxpb39 +2tfoureightgvnl +79six +sixvktfvkmv5xhfgnine +86szmzzfntxxltmkffnczrjvthreethreethree4 +threethree1sixdkmjpmxtwoonezktwo +tlp189jnmskmcnkhvmn65 +41nqvvc +4xrlpc7c82oneightk +six1threecxxtttdthreeeightjc +gbhkzvnrxfourndtfc6 +fivesevengjmnbpdvcdeight6vj6 +vfjdp8 +8dfrttfrtrtfour35 +887 +714eight1tdnt29 +xbmhsbn3 +gjktjcn3kf +1327five1eighttwobfhtqcjjms +pc615 +one1rthreefive +fcjsktwo9 +lhgqvtxcntrljlnhdllthree1 +5xxmtwo1dkjpchmzfz9mndbrcbzkh6 +6zxdxzxt62three37 +cveightwo6 +ninezdvzbkggh4one63 +three7fivesix +3vcdrd881vlmglkfone +2ninenjcvq4 +5jltkfhl5onehthree3 +8eight4rgfrhseven +6vqjgxltqd18two7onelkmc +xffld1jjlqxfz7xjvxfspzrkztsdtsone +9szzhnfpssevenoneeightfour42two +four91mfnrxkcckd6vbhtxvvmzhpqqrkzxv +eight2three6ksfive +94eightslkpbf5zc5tm +4twottthree91sevenone +kjgfgq226fiveseven2 +kjrrgfmthree36ck +sevensixfour24one8 +dqj8eightthreeqzcz8 +xtwo5pcdl3eight7 +one131xnghfczdpvsczkrxhjt3 +j4qqx +hncrcntcmmpkn6sixzvjzkgr7 +9nnzltv7mclrhhgnmq2nine2 +6sixeight9 +5jgnhjmdc6xsdsl1five +onerdtqzhpbdflxvrhnpjqdqzn39 +rcroneighttvnfcngrfblvmeight7sevenonevknxtpfour3 +mcfjn569 +44 +84six +nineeight3 +one916 +eightfourseven5four +nine1gpmqdxkzmr6six +two4fouronesevensix1nscgll1 +eightthree44vxbjmvbpfleightvgbjxcgrjonesix +6vmgscbtpsnkktmbdjpmmlv +1one1 +ttwo9sevenninetwothreephpfrtjztn +cxlzcpdd32dhvvcsgdcc49rhhrqpkxtwo +8fourkkrbjsqt +rxndgg4lhkcphmtmjvtqkc9qsevenpcmftwo +jpgrzfvdx3858fourthreesix7 +7krxc9mjhgtonetqd +eight2qhspjfm +gsxplbone2pffltsp4two +hqtwonethree939zknfxrqjpn4x +eightsevenone4sevenmhxbbqrtwopgvvgn +6three5tlffrcdszg384 +frqhjmqntneightxgtldk9qpdnncxgnmqzbzkqsxz5 +vsf42twolzmftmbbb346 +7eight47 +9four94kpmvbtblbxthreefourone +2eightctvgglxjgxvghmsbbfivedbnn +qxkvzrpkj79lkqtt +jfjgzhrkpc77nine4nine8 +prqrpms3ninefiveqnhtngpbsix +gqxbtbtvdoneznqsfpf9threelmhn +four7sixjrrpqdjtbsfivetvcngclhrprmhftwo +9sevenntmbflxvf1eight3nine9four +twoqgxklrmdzntrbtvcfsix6 +zzt8kt2 +ninethddninexszntlm9jnqnbpb4 +lcsfourxdsk9297 +f2v96nqfour +2tqsdl +7onethreegeight +47q667gtgj2sm +8four7sevenfseveneightninettlqkc +5ppkgf +61threetwohxlxzbrlfjk +6fcfbvhpzgl57 +five2tjkc5three5onepqlgv7 +five925ltvrgpzm +jjstljfs47threebcg +37seven +8three47eight2pqxcvbn9 +threeeightrdndbtfpbszscbqzlhtq84 +xvqtwoeight4twoone2seven +fourpcqvbcfvz8onefivev7xvtxdpbnone +3956fivethree +sevenlmsksix55 +eightnine17 +5hgqmlb +eight91pfnngffzl8dxvlnnninektlmqq6 +5one8two9hh7 +qfourlvclhf8four +9cfgrkdmeight +foursevennvxcmjzzpjtwoone4onezlht +njpjsceighthqqeight33two8ppjf +four5djlmjfive99eightonefour +jcf2s6gmzrnjrjkvfkgone6kbhjc +threeninedbskzbqlb8jpnine7 +onekbddzcdx5eighttwo3 +3xms +mmvvxmpthreesixone96 +3djjfsixtwo7threeeight1 +339 +3seven6 +six48nine533oneightv +dkvvxngfrvhktzx3sixvqtkpqztzs49 +1three5ldzvllvqeight +9hn8mdcpvzqlzctwo922 +164k7 +sixsix4c1tnkmzkqconejvdkcdfntpfkpsdm +31qvdnvdqthreetwofour8two +htwone6fkzkrdfcpqlnxlone +2875 +6eighthj +7lcchpx3x96fivefoursix +kone1ptnkjhks65sixrsseight +23sixninefour5 +xdnzfbpq2 +hbznxkpmktwo3six6sevenfourfive +tbbcrzdtfive42eightsixfourthree +5mjgvsrrdlnrvlr6ninevlzrksfj2five +cftlmrsptdjtsndl2eight +snmkjqprhk57ninetm383six +krxqxdgdp7fkgtmdtbx11fivenqncrnhcone +3sixmcfnf +7jkfgvjlbkfvlmf9 +sixgljmbvxoneseveneightpfvvnl8 +523eight6 +seventwoone3rnxghtb9sixbkqch +5hjzzvkbls9qrcqtrrk19hbrhszxfive +8kbhdp483four +seven7five1 +dklfjdmzc15zchbgmbqkgzgkn1sixsixeightwovz +8sixqbpgkppjktwooneninethree +seven16 +sdqvhfour2glrqkmj5fiveonegzqsdtgqskjcmgg +twofiveoneseven1rqjvrrxtwonen +rmgdlx9cskhdjlmtwobvpnjrcxbfftd5 +93mcfoursix4 +gst66jphtlbtngqdqdnonefoursevenseven +seventwotntksixjrczhp557 +svjgzfkbj3five +threeninetgqdgnmr1xxnxfxlninertwo +jjhpnine33hjnine +twojgcp9 +vgkbmkzrbbvlhv267 +fournine1eightfourcdvvdgkmkndbkrheightone +1onefourthreecqbffjdvtzbxdc +mmgvhrmftnmtdkqgf29 +7qnsfqj3one +qhr933three5 +pqblftsix3 +one7sgsqvszkd6ztwovcrmqbjthdthree +1qgqtnfive487czvxsjk +37jrggmdknnine +3sevenfour7sblhjqg9fourgchqkdg +nfxdxlssvgxxvzgksrkxqtwoffpphxdqjzh9seven +4qjhllxzdb8sgbgksxbblsmftd +twofivegddmhcplptf13five +twosix55 +3zcftpvkbmzpffpjrfouroneseven +6vpsixhprqhzthree +eight7ninemsmfbnqkzmqfd +nbrtxpkpb1733 +nine33jbrkqlnf1 +14lgl +eightjjvclfxp9 +fivetnmksk8cp6 +dpxcqhbkvlhccb1fntmcrjjgccnszct +lbjppg3hrgpzstfqgbcrzbmn66two +dxbxkzmpzzthreestcvtvhftgzctnvnshzgqtbgxlrqkthreefgxdrfmm7 +31lklpfour +nineonezcmrfppsvbg7seven316 +9cxgcgjsd8ctgbh7 +9vdnine4five +2jfkrtdxvzq +qgzgclpt8jltqzkpvddtm +614two +pjb92two5sevenfkb6three +twosix766five71 +86vbnpsixthreetwonevng +onel2one +4ninesevenpgbqgpfgkfzdsixmmfive4 +7xgcmqfqmk7twothreeninepdt5 +sdonefour77one +fourmfhmsznxffzpgdonegck6nine6 +rxjspvttx6nine1knbsl +pljd3fourone8 +8onevhpeightz94seven +jtmdhqjn5eight +onefshb1sixone2b +seventwo4gnrsrpnfppseven2 +147fourfour +9hfjjmgrzntssjpxcvbzpvmqzgsd54twonine +mprnmlhxsdtntbknine1 +98onefivethreesix +gd6ninejhsrhsevenksvkcone5 +fourd9xkcsrncpdsbqhcqg34twoneb +pbx74kfivefourvmslqvfbml +dmxmpl71 +594shxctmq6qkmnbrm +5qrhd8jmmthjkdzhrxf6two +four4six4three +hlrsmmjjvshzztxrnznmseveneightfive9sjddhlfvftbtd +fivesbcklfdrvz4pcxsvdcqpeightgj1tqkfnv8 +tthree4one9 +nine4sevensixone +eight5threethreesevendrctkthree2 +4ngzcbtwo451bpvbtqdvk +9two1tdjdlrflshfourjlkdctfp +sevenseven6132sxqfspmvxjfvh +fourfour28562 +seven6gsevenrtcsldgztqthree +sixtfmvfnkqxlp3sfsmdlfgh5nine +tjeightwornmddbpcsckjrzdtvzrxfivef4 +gcv42jfcdftseven1 +166eight73 +5tlcxlscsgmrznhlgfgkqdpksjllz +2one7twofivesevenqxrdvbczfmt +1bdqfdmtfrtx2svdltfzknnqssvxvsdkzvd3six +rzztvfourfive754fournine +71vfsixrjhdqqj +one63csbsvkqmkjt +3seven4fourthreeseven36 +bmkr6threefour +5fmr6four6mxqj +3five1one93 +5nrtfrdhfv4mkkhnine4 +mklgxhrpp3two +hpfrfpkddsdqfgbhtgfourthreetvdvjrfr5 +five6ttmzjcs +tlbzoneninesixsevenpddssz2 +prceightwo1 +vvktl7eightltmtpfcrkndtkglhndhvrbtfv6tjgrzqv2 +sjpzgmvmddttrcmnvzseventwocgzc4 +seventvxrsbbbzrkfbkbcrbdsdtv456 +ttwone12threesix +85nine +hdgxncxv83 +58sqpgnine +65mpmptlg +threefourxvmdkhlqd2three8xfphd8 +rdptwo22threergcfdntchfqbsseven +98jbmmhznxvrqkdxseven1onem9 +eighttwo1twothree3sixjbjqgzx9 +9klnfhhx +7three7five +jlvrcqflvfivenine7cnx +fourrr2ktmdqhsteightwot +bkjgtqxg9fivenrsktmkmxcfbg4 +eightjj95six +6threeonebmpqrnqgdqlkkqc +seven5bbzlsnvjchbjgxh +lbsptf1threefour9 +37threeeightcgfxdonebhkrdnfive4 +379263 +24vmbb +9v +1seven15 +slxpsix3threeeight64jlrnkmkrqr +ninedjlvkxqh24 +sneightpssteightpdfzqjcjgsmseven7one +sevenninehf6bxjtfntwo +four2cknjgdkbqdvl4 +qxrzdhsjjkmtggt42 +tgsjddrgtkthreefzlvgrsix32onetwo +3zldxonenrghfnhhmptbpgcl973 +8ckzrgrzbone4sixdspxtwo +xvxzprh1mbpspkrv +lgchfzs6sixthreeksix3khvhldq +sixonefour2mxslvpdhk7 +6sixsixbghxppnztxfive +jpdbbeight57seven +2onethree61jtnjjcq +63lfsznprjddqpfourcrkthree +ninepqmvc2xtwotcjcfcvht +1bcrpone +pntsrhj725xblt2seven +12nine1 +8twooneseven22 +hfrbxdlfzmjvdslseventhmtqzbtcmsqbeight5fiveqlglhclrh +three6htff5nlzslroneightxm +hzcdc6threeseveneightmckdvg4 +tgpjgvlq6nineseven8six2foureightwozbz +three83bbbfsg +75bpmqvdseventwo9four +2nine8vjdcgvfns +rjndbbfmppgd67eight3hztlrqv6 +onefourfour6 +two5six1 +954ninetghsfnnine12cmp +6one8nfzstqlfive +seven1sevenjrslmhrfivexsk +nineqjgmh1onekqblsvjkdn2five +eight94mzsevenvtkkv1cdqgv +xsix4sixnine +3pbxzxrsd +77four9 +8zcthreethreeninettdb +c4eightsevenxqnhvclfour +gxbkjmfhhzlzrbzcmjmmnqxlsevenninefour4jcbgttq +9zptjlhzkls1fdfzxvpssleightsdcmfour +8oneone9one +1threefive4zkslknvmr +9seven4jninesix834 +sixdpgkdnnt4kjzgrjtcqlqq +1qmcgnclrdqrc +5xhlzgzpzbgzjcsthreefive +mrgcpmnnsixeightfrtjfourjlbcdt3 +129twokqmtmdj +fourskzt382mnznt17eightwocx +9hnx914mtsnhnxtgn6 +81psmkhzk3fiveltthree +lhbtwonetwo3dvrtmpjxk +x859zhjsbzjpjrtrp6 +73mqrrpdrs +43d73rbddvrz +rnmrrcndm6 +x6rrnsmpgqmp3three1 +pbtnndfj2onetrvmvcftf4 +four6rfoursixfour5three +69nine2szkcnjbmcvjtbjbgnmssghfdlninetwo +one92phhclzfsfxqg +hzc2 +fivethree8threedttx +pjdkcdbxt5 +trgggsgx92six +9ninethreeknlvmb +eighttbbxhxcmrjqxkbjrdcjv5nineeighttffour +9cghvbkpmkt +sevenzhlcljtqcntthp7rr2 +3fxgjqpbp +7nineqxqvhgf1plh4 +2fivethreeeightsixfiveqz +twoeight8 +fvvjphpmqffqjchvtfivemseven8jmlrk6troneightvf +three46 +tktkqsqskrpxl7thfrqnpdkzcjxvfmmbfourone +9twosxgk +g3scthxjb33nppgcone +mxmr17fvcgh4nine +vz82 +2threefivenineeightqmjlcsbqrcg4 +xptfourthree7mcfeight +bdthlfbqbczmlh56 +onesixlpqxqlkxxkqldhd5twop36 +seventvptphkhhjvslhtphntwo2cfnn358 +shjlthfxpfive4rzm6eight +three565nine4 +xfjoneightsix47sevendvtxtfive6 +9717one +rkmhlxzpxgfourthree7qhh69pfds +3threepvknzvbmbrvljtcx13three2 +1zbhchxzlccgfvbdtlmfr +28hqpxjvxcmnqtxhhgninethree +eight3phxhpsxnz6nvgqznb9h9 +2klvscxmt94fourthreekgmqgjbhnzrxtwo +7eighthmbvjlfseven5 +k45ls +1qkvvbvsixsix8threeshqknine +4928plcrzs6 +gsskhbkmfzq8 +6crvcnine3six7eight1six +fourfive311 +lqdjctn82sevenjdm6twoonesix +8three8pqhmjjc +hgn6mnpmdmcpzceighteightnxkvjjfrninejmpkrfzcgv3 +ln7pqvg3sevenkqtztcpjrxeight +dqbrjj9fourseven +4sevenone16 +9cxtchrmsd3fflmkdzdgp +6349 +sixsevenlqgzcsvnd1 +kjfcbgeightthreejvqgk874 +2vkrvzpmfv4eightwob +mhjrqbvlmgsixthree74 +fivekldbzshd37 +seven11fourcgvnqr7four +fztzttvmx4vtwoone288 +5fivevlbqczq1 +twoncljq5 +jljz388kklzbronetmmf +92twonmjmkhgqfhx66 +2rh9nine14seven98 +7hgzjblbxpkltmjmlpscd4svtwo1two +xcchzd8fourhkrstwo9three +lxgxlsdkvcfxsclj4cqzjgjgvtmkjlhxfnmfc3 +86hzhn8eight6 +qhsevenvpg4hzffldbrvpxxpthreeqpvvdndv +five6eight15 +mhl8rcdkxx8 +3sevenv +one131eight86fourk +7hsnjrnlcnb8twosevennineeight1 +2khhfivejgbknv65 +8lmfd298dlnmszrrfive +one5ppczgjzzsix +nine6fchgqxsdjhqtwoqpqffhn6ncjxx +bfivehtndrmm62 +829fourbjpmbfqkqgsixtwo +xvcdsix3five +sixhqthreeninethree7 +gpsdvj3zpztgcndvcxz12 +seven3fglvdzxzcqfive7four9five +3five4gzgjbpptwo +nine44four8 +4143two +fourpcjhfjrxdhvzf2dkmszvtjx +ninecrxdkznbg8p72nine2 +sevenrbzhktn7five7sixvklcksmb +rndrrfhvl4zscdjmxcbrfvrxxjxcc1jjfsjntxzqp6eight +sbnkdhrjrthreecvxqrfxccdpmqsix5jjpkrxfqlnxbzlzskcfgr +two4xdtsdjtneight +teightwo5k4eightmtheight +eightzlc6lgtgxsvckm56 +qzrzhnchttjnjxjnine4seven611 +ninefiveninefqtd37eighthzghljhhv9 +bcbbbneight1rqjtnnzrv +ninegldjhplfthreetnqcbrllpvjtlthn9xkbqkfourthree +nineeight4 +4zvghdrbl7onemsbffzkjrb265 +lthreesix7two +vvkfivefmkdsbst66 +3rxdgrfgdtwofourseven +onegzbdndnqkkckpsh1vftnlhnqjcvrm4 +gpjld3lcvtzckpqrdghlpz +3ngvnzone3 +sixfive8eightnine +tscdrcsvztsnktrj495sg +9twojbzsqv64smmhbqc +8ninefour +ttlrjjxm41four +qtwonekvlm9tnmzlvpzzs1 +twotwo1fiveninelcl +8rfvffourtwotwosixpqmthjsrgj3 +nineeight2seven +n9 +two7fivenrgdqshs +nine5foureightwom +4tworvqpsxzhn +18ghsmdrjlq8rfpmvqtgcl3fournine +8three7qfskg +nine82 +41zb5 +5cdpnqzfbthree +247pgfzbhpbkxsk88three +xsnjsqrrpck8two7 +qmlbtk79vqnzqv +pkcmsixjhqtfzvjv23 +1nine1lnzeightlpxpssdgtsgbvqmftmnv2 +threefourhkfckgvqn721 +onethreegzninenineone31 +kttwo4gcpxpvrp +4six4632 +7vmkqlqfbbzkksix3 +jsixpckt8six142nine +two753six22f +twotwokjgftjhnhp6onefour7hqzlcbkz8 +ghmjbfv49pls68 +three1889twogbcjkkzc6seven +twothreethreevkmlsplbgninenine4six +seven7vhjqfmklxsvc +pxnxlqg91 +fzrbbvfsqrgcgsjjrd5 +skcm59mfgkjvcffourhqzsbpt12five +three9eightvfksbfcf18vlvgsixnine +oneonefour9eight +zjrxbvxtjbqtqqeight75rf +flk6gjsixtwo74five +4jncmngfmqxs1four9 +1fivefivefournine58 +274 +gjjzjfplnninetwofourlgpjfpnkhsixthree3 +4jnthree75tdxnhpm7bv +three82jgvgjthreev +sevenfour8 +threeqfrhnkfkj2jhzllpn +one859one +8xtnbtqqh41fourmgxzpdv957 +37126 +zzsixsevenfrszzvchj9hxhdcxmxqqckclmfm +sixsix79nine +s2mkfdqmcznztqtgddtwo +hpvpdczjvkf8two +6two73hdnbrkgblgfiveblgzksljjjskfpthree +7kndzrhvcnstgfxjlff9twoninervrknsffmfzmdhtth +three81kqcfplcf7 +fivegtfbnspddkeightmmv4bzksixeighteight +596ninefqrfvpfs +sfpzkhxqp7 +kqd5 +1sevenljlmfh6 +75sevenxpzv8ngffsnm8 +rxqnshcskglgkrlhzone4 +1threespckmrpdnxfoursgqsevennnrhjkcrlbnine +hffpvhxzznnkg86one61two +7bqm5sevenkdnmqpqfvvtbsct +3sevensixnineone5nine +two1five23dgmqsgzftflfmjseven +jzmltz1jtlnsbgtsix +nine1sevenjltnln8fivenine +svmzvnr8tfxqlxnc1 +sixrmcsqtphlk5 +fourjnpshskvmsqscq8threethree8six +3threetrqfhnbtsbckkvf +5fcmhxjhpr75zkcbqgltq93zcdm +eightlzjjtzk3xlbvgnsfoureight8 +hrrxxnj6nine1two +zbnj6txxhqgdtq21fvcjxvkkrsrrdmkrmvtbjhs +threex86three +onesevenone6four6twogjtqp +92onethree52 +qgzcfour9eightbsrseven5 +rnrlmtqdqlb6 +sixeightzgbf788five +sixgnlbxrfrc1jseightsixeight +nzxgkcfive44tkblnn58jbmdg +49fivefgsk +one8zqztmlmss6fiveznccsnnnzqk +6fivesevenfiveqrvlmdjvjxzvsix +sxdgthcx9 +93qlthreefivezmk +xvsrgcsqbsqhdnqhbmcgn39ninesixszgtlslqb5 +7sevenfourrpfqkkrm5 +vcmfthdpkzsjpjt5six +zqtrk35lvsg1jkdfour5 +7threegqzhcnxcmcrpgjkttbmxq5 +2four25seveneight9 +3h +xcspfcvfive37three7three +nbsnvhg197csnine8gfttndsf +xzztbq981vfbcmrv6ddrhrnprrnj +5kv672fpd +two2nine4fourl9foursix +ghngfb2four67qsfhpsb +4ninetwobcr49sixfive5 +2threethree7onefour4 +824zpsjjm +four6twosevenqbmzone4fourph +ctvmbrvksix18kz +eightfive9twokrpsltfhkjkjkdqlszzs4glxxtgktsx +2two7hxrncxqeight +6121two46 +fivefourthreefivemkmb5fourmqfhmlrxmm +fiveonefivevbtbzrone9tsix +oneonethree5sgs9 +cdvrrsm53qfvdzhvnlprvfjcx +jtflvmkdnineone62klbvbzzltscsvmbsbp7 +3mjmrxl3fourqfqhrknblcthreelfmm +seven1vjlvfmh5flmnhfzsixfbdsjdkxqhvmj +sixfourninefiveoneklpsgrtthree5zcpxs +eight73pjvcbb +gdgbgzdlgjt9hklsxglkrtwo1nchtbvltmxnzn +87sixkfmrdmdx +jrpjxhqkleightttpkqqrtzvb5threerx +xdrjhrrnmnblnbtone8one +618gnvslkkmm8 +tqrctvjjdone39 +6zs9lninekjbrm1twosix +23mxsmvfthreefourkhvxmqg +onemkhn4seven3mtphqnqb +one5foursevenfivezpgvjmdhl +2mskpg1threevdjjlzbrbsevengfgmqvd +1hrrxgxgzhj2eightfive +rlleightwo2vfq +2gss +4lndrzf7vcfffcb +four5one +three5lxddbbpccp6kkpgxm +sixcbqfivesixzfgbzszq3tqcfqk +8xpsixrcfoursixfkxh +rqrtwojhcfive89fourthree +5ninesixknjmlcjmnsmv2 +18zgjpthfsix2ncmdfkcsq3 +tsxbfgzhjr55seventhreesxnnjhninefive +three61rqljxqdbch +threelhqzdvxnsgkmthmbd7 +54two5dnhx5 +btc4ggbfmtfscgzfourtwothreeqptmrn +rvqkbtvg331nine +2fourkrgdhvkgzrhvqonefive +7twoxkcpbfxthree +bmzczfl54oneeightqslllrcjkm +sbjgbkn89 +9rpq83seven +fiveqmqklgxkqrrckkjqsxkkfjzzdml87seven +74one27 +45four3 +pbhcrscll27five5 +7bbmjqlxv1dbdsvsc +sevenrhqt9sixthreethree +4sr8five +kc1 +1eightlkjrvmpt4sixtwo +1oneddzcqhmgd6 +feight6tmqcj4four +five9mj7mgjqfhshvhxskjsix8 +six99eightg42 +vfhvmxnvhxnonekrhfzqpseven27 +866three +eight5one118 +clqlseveneight8dbrqdlcf7 +9mnlgvcfmlrsrxfp7six +8mzlgnnqddptwoone +3bqckbeighteightthreesevensltsixf +eightfive37688eighteightwof +sixfour2one4zzqtdp +mkx1twofourxseven67 +1jhcktvgninethreexdmfqdbjxltzj7rhkdbvf3 +two16 +5443 +1three52nine7threemszlkc +jsgqfbhmcmtjmxkq1brl9eight6 +fzvgmbbeight8 +861snhtzkvcpnr4 +b6kpxgcv71six1 +c5four7vcnqhd84threefsklxc +lcpdthree2three9three +kljtp912sevenctg +241zlv59sevenqdbvddmrhtfgrhxgxmb +hksp3gdmcldnvbts1 +xvcpr86btlptpnphhsix5fivenine +fivehgtmtxtwothree1seven +fpjpnrtpthreegjmfsjpcsix4twoonejqrr9 +2hsrckv4639six3 +fourtwofour3 +2kggzqfourfourseven +three526seven6gbmjbqkncg +crstsqhvt98rhzvhsshthreebj +xbhcfqvplfive9one77 +7256hlnmqlhth +5rttvcfhbjzoneqdbhvtwoneb +7mxgmsvxzzsevenclzbcq3twos +xcmpjgk9 +eight5cnntwopzjrmgbhq +rvbfnddhg25lpthcsfxfdkmseven +eight82cppmnpvkvthreesevenseven8h +fourhmpknkfdtwogfhrgthree84 +6six3599fivejhmjzdzsr +sevenbngxnjljfivegcvtmnt5k1 +twoone58nine +29jfctbqssvrtwothreeg +84kkjdjjp +threektqgtgcrccbsnsqpcfxtb3vxtdfour2hgvdg +6fivejttmkvvpntvqlfpbjbcfkcztltwosix +twoseven7qkhzqlx9four +ktnxrj2sixsevenrcnqbksgbgdfxrdqgz +236four +grbhpnjrtvrbslnfgthree47vbpncxqfourfp +5sevenkrlmnrjsix4 +5fivekgsxtbvkk +2two4 +lkrjlsz7mgv9525p1 +nineonebmfdxxfqvvkrblrd9 +5six6cvmqttbsxkzg +42seven13four4 diff --git a/2023/full/day02.txt b/2023/full/day02.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day03.txt b/2023/full/day03.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day04.txt b/2023/full/day04.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day05.txt b/2023/full/day05.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day06.txt b/2023/full/day06.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day07.txt b/2023/full/day07.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day08.txt b/2023/full/day08.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day09.txt b/2023/full/day09.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day10.txt b/2023/full/day10.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day11.txt b/2023/full/day11.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day12.txt b/2023/full/day12.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day13.txt b/2023/full/day13.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day14.txt b/2023/full/day14.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day15.txt b/2023/full/day15.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day16.txt b/2023/full/day16.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day17.txt b/2023/full/day17.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day18.txt b/2023/full/day18.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day19.txt b/2023/full/day19.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/full/day20.txt b/2023/full/day20.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/justfile b/2023/justfile new file mode 100644 index 0000000..fddee6d --- /dev/null +++ b/2023/justfile @@ -0,0 +1,12 @@ +#!/usr/bin/env -S just --justfile + +DAY := `date +%d` + +new: + cp python/_sample.py python/day{{ DAY }}.py + touch full/day{{ DAY }}.txt + touch samples/day{{ DAY }}.txt + + + + diff --git a/2023/python/_sample.py b/2023/python/_sample.py new file mode 100644 index 0000000..0f81824 --- /dev/null +++ b/2023/python/_sample.py @@ -0,0 +1,27 @@ +import matrix +import shared +import itertools +import functools + +# @shared.profile +def part1(rows): + pass + + +# @shared.profile +def part2(rows): + pass + + +def main(): + rows = [row for row in shared.load_rows(15)] + with shared.elapsed_timer() as elapsed: + part1(rows) + print("🕒", elapsed()) + with shared.elapsed_timer() as elapsed: + part2(rows) + print("🕒", elapsed()) + + +if __name__ == "__main__": + main() diff --git a/2023/python/anim.py b/2023/python/anim.py new file mode 100644 index 0000000..a1a1def --- /dev/null +++ b/2023/python/anim.py @@ -0,0 +1,45 @@ +from matrix import get_size, pmx +import imageio +import matplotlib.pyplot as plt +import numpy as np + + +class Animate: + def __init__(self, mx, day="CHANGEME"): + self.mx = mx + self.day = day + _size = get_size(mx) + self.height = _size[0] + self.width = _size[1] + self.f_count = -1 + + def add_frame(self, frame): + self.f_count += 1 + self.write_frame(frame) + + def write_frame(self, frame): + current = np.zeros_like(self.mx) + for y, row in enumerate(frame): + for x, col in enumerate(row): + current[y][x] = frame[y][x] + fig, ax = plt.subplots() + ax.imshow(current, cmap=plt.cm.gray) + ax.axis("off") + _figpath = f"gif-{self.day}/{self.f_count:05}.png" + plt.savefig(_figpath) + plt.close() + + def animate(self, frameskip=1): + with imageio.get_writer( + f"gif-{self.day}/day{self.day}.gif", mode="I" + ) as writer: + names = [ + f"gif-{self.day}/{x:05}.png" for x in range(0, self.f_count, frameskip) + ] + print(names) + for filename in names: + try: + image = imageio.imread(filename) + writer.append_data(image) + except FileNotFoundError: + pass diff --git a/2023/python/day01.py b/2023/python/day01.py new file mode 100644 index 0000000..6667dcd --- /dev/null +++ b/2023/python/day01.py @@ -0,0 +1,66 @@ +import matrix +import shared +import itertools +import functools + +NUMS = { + "one": 1, + "two": 2, + "six": 6, + + "four": 4, + "five": 5, + "nine": 9, + + "seven": 7, + "eight": 8, + "three": 3, +} + + +# @shared.profile +def part1(rows): + total = 0 + for row in rows: + numbers = ''.join(filter(str.isdigit, row)) + total += get_total(numbers) + print(total) + +def get_total(numbers): + tens, ones= int(numbers[0]),int(numbers[-1]) + return (tens * 10) + ones + +def loop_row(row): + digits = [] + for idx, _ in enumerate(row): + if str.isdigit(row[idx]): + digits.append(row[idx]) + continue + for x in [3,4,5]: + next = row[idx:idx+x] + if next in NUMS.keys(): + digits.append(str(NUMS[next])) + break + return "".join(digits) + + +# @shared.profile +def part2(rows): + total = 0 + for row in rows: + nums = loop_row(row) + total += get_total(nums) + print(total) + +def main(): + rows = [row for row in shared.load_rows(1)] + with shared.elapsed_timer() as elapsed: + #part1(rows) + print("🕒", elapsed()) + with shared.elapsed_timer() as elapsed: + part2(rows) + print("🕒", elapsed()) + + +if __name__ == "__main__": + main() diff --git a/2023/python/matrix.py b/2023/python/matrix.py new file mode 100644 index 0000000..fc6e830 --- /dev/null +++ b/2023/python/matrix.py @@ -0,0 +1,425 @@ +from copy import deepcopy +from collections import defaultdict +import math + +from typing import List, Dict, Tuple + +split_word_to_chr_list = lambda y: [w for w in y] +split_word_to_int_list = lambda y: [int(w) for w in y] +split_line_to_int_list = lambda y: [int(w) for w in y.split(" ") if w] + + +def split_x_out(l): + return [x for _, x in l] + + +def split_y_out(l): + return [y for y, _ in l] + + +class colors: + # HEADER = '\033[95m' + BLUE = "\033[94m" + GREEN = "\033[92m" + YELLOW = "\033[93m" + RED = "\033[91m" + ENDC = "\033[0m" + BLINK = "\033[5m" + + +def apply_to_all(mx, func): + for row_num, row in enumerate(mx): + for col_num, val in enumerate(row): + mx[row_num][col_num] = func(val) + + +def rotate(m, right=True): # -90 + """ + Takes a matrix, and rotates all of the values 90 degrees to the left + """ + x = list(zip(*m[::-1])) + if right: + return x + return [list(reversed(y)) for y in x] + + +def load_matrix_file(name, func=None): + """ + Open a file and split all space separated word lists to integers as a matrix + """ + with open(name, "r") as f: + my_file = [] + for line in f: + my_file.append(line.rstrip()) + if func: + return [func(x) for x in my_file] + return [split_word_to_int_list(x) for x in my_file] + + +def find_in_matrix(mx, what, one=True): + coords = [] + for row_num, row in enumerate(mx): + for col_num, val in enumerate(row): + if val == what: + coord = (row_num, col_num) + if one is True: + return coord + else: + coords.append(coord) + return coords + + +def get_neighbors(matrix, x, y, _dict=False): + neighbors = [] + # left + try: + if x - 1 >= 0: + if _dict: + neighbors.append({"x": x - 1, "y": y, "value": matrix[y][x - 1]}) + else: + neighbors.append([(x - 1, y), matrix[y][x - 1]]) + except IndexError: + pass + # right + try: + if _dict: + neighbors.append({"x": x + 1, "y": y, "value": matrix[y][x + 1]}) + else: + neighbors.append([(x + 1, y), matrix[y][x + 1]]) + except IndexError: + pass + + # up + try: + if y - 1 >= 0: + if _dict: + neighbors.append({"x": x, "y": y - 1, "value": matrix[y - 1][x]}) + else: + neighbors.append([(x, y - 1), matrix[y - 1][x]]) + except IndexError: + pass + + # down + try: + if _dict: + neighbors.append({"x": x, "y": y + 1, "value": matrix[y + 1][x]}) + else: + neighbors.append([(x, y + 1), matrix[y + 1][x]]) + except IndexError: + pass + + return neighbors + + +def valid_neighbors(matrix, x, y, criteria=None): + if criteria is None: + raise Exception("Please pass in a lambda for criteria") + cur = matrix[y][x] + neighbors = get_neighbors(matrix, x, y, _dict=True) + valid = [] + for neighbor in neighbors: + if criteria(cur, neighbor["value"]): + valid.append(neighbor) + return valid + + +def sum_matrix(mtx): + total = 0 + for row in mtx: + total += sum(row) + return total + + +M_UL, M_U, M_UR = (-1, -1), (0, -1), (1, -1) +M_L, M_R = (-1, 0), (1, 0) +M_DL, M_D, M_DR = (-1, 1), (0, 1), (1, 1) + + +def get_neighbor_coords(matrix, c, r, diagonals=True): + height = len(matrix) + width = len(matrix[0]) + if diagonals: + coords = (M_UL, M_U, M_UR, M_L, M_R, M_DL, M_D, M_DR) + else: + coords = (M_U, M_L, M_R, M_D) + neighbors = [] + + for _c, _r in coords: + try: + value = matrix[r + _r][c + _c] # Try to get a value error + if r + _r >= 0 and c + _c >= 0: + neighbors.append( + [{"c": c + _c, "r": r + _r}, value] + ) # woo, no error, this coord is valid + except IndexError: + pass # okay we out of bounds boizzzz + return neighbors + + +def line_of_sight_coords( + matrix, row, col, distance=None +) -> Dict[str, List[Tuple[int, int]]]: + """ + Takes a matrix, a row, and a column + calculates the coordinates to the edge for all four cardinal directions + + returns a dict with a list of tuple coordes TRAVELING AWAY from the + requested coordinate + """ + height, width = get_size(matrix) + + col_ids = list(range(0, height)) + row_ids = list(range(0, width)) + + if distance: + up_ids, down_ids = ( + list(reversed(col_ids[:col])), + col_ids[col + 1 : col + distance + 1], + ) + left_ids, right_ids = ( + list(reversed(row_ids[:row])), + row_ids[row + 1 : row + distance + 1], + ) + else: + up_ids, down_ids = list(reversed(col_ids[:col])), col_ids[col + 1 :] + left_ids, right_ids = list(reversed(row_ids[:row])), row_ids[row + 1 :] + + left = [(r, col) for r in left_ids] + right = [(r, col) for r in right_ids] + up = [(row, c) for c in up_ids] + down = [(row, c) for c in down_ids] + + return { + "U": up, + "L": left, + "D": down, + "R": right, + } + + +def line_of_sight(mx, row, col, distance=None): + """ + renders a line of sight coord calculation, into the values + """ + coords = line_of_sight_coords(mx, row, col, distance) + los = defaultdict(list) + for k, ids in coords.items(): + for _row, _col in ids: + los[k].append(mx[_row][_col]) + return los + + +def coords_between_points(point1, point2): + y1, x1 = point1 + y2, x2 = point2 + + coords = [] + x = 0 + y = 0 + + if x2 < x1: + y = point1[0] + for _x in range(x2, x1 + 1): + coords.append((y, _x)) + elif x1 < x2: + y = point1[0] + for _x in range(x1, x2 + 1): + coords.append((y, _x)) + elif y2 < y1: + x = point1[1] + for _y in range(y2, y1 + 1): + coords.append((_y, x)) + elif y1 < y2: + x = point1[1] + for _y in range(y1, y2 + 1): + coords.append((_y, x)) + return coords + + +def get_size(matrix): + height = len(matrix) + width = len(matrix[0]) + return height, width + + +def row_col_from_int(matrix, x): + h, w = get_size(matrix) + col = x % w + row = x // h + return row, col + + +def matrix_of_size(width, height, default=0): + return [[default] * width for x in range(height)] + + +def set_matrix_dict(m): + for x in range(len(m)): + for y in range(len(m[x])): + m[x][y] = {} + return m + + +def pmx(*matrices, pad=True, space=True): + """ + print a matrix of integers, zero turns to `.` for clarity + """ + if len(matrices) > 1: + matrices = list(zip(*matrices)) + for row in matrices: + r = [] + for col in row: + r.append("".join([f"{int(x)or '.'}".rjust(3) for x in col])) + print(" ".join(r)) + else: + for row in matrices: + for c in row: + if pad: + f = lambda x: f"{int(x)or '.'}".rjust(2) + if space: + f = lambda x: f"{int(x)or '.'}".rjust(3) + else: + f = lambda x: f"{int(x)or '.'}" + if space: + f = lambda x: f"{int(x)or '.'} " + print("".join([f(x) for x in c])) + + +def ppmx(*matrices, pad=True, space=True, zero="."): + """ + print a matrix of anything, Falsy values turns to `.` for clarity + """ + out = [] + if len(matrices) > 1: + matrices = list(zip(*matrices)) + for row in matrices: + r = [] + for col in row: + r.append("".join([f"{x or zero}".rjust(3) for x in col])) + out.append(" ".join(r)) + else: + for row in matrices: + for c in row: + if pad: + f = lambda x: f"{x or zero}".rjust(2) + if space: + f = lambda x: f"{x or zero}".rjust(3) + else: + f = lambda x: f"{x or zero}" + if space: + f = lambda x: f"{x or zero} " + out.append("".join([f(x) for x in c])) + return "\n".join(out) + + +def view_matrix(matrix, y1, x1, y2, x2): + lines = ppmx(matrix, pad=0, space=0).split("\n") + for line in lines[y1 : y2 + 1]: + print(line[x1:x2]) + + +def highlight(matrix, red=[], green=[], blue=[], blink_green=[]): + """ + print a matrix of anything, Falsy values turns to `.` for clarity + """ + mx = deepcopy(matrix) + for (y, x) in red: + if (y, x) in blue or (y, x) in green or (y, x) in blink_green: + continue + new = f"{colors.RED}{mx[y][x]}{colors.ENDC}" + mx[y][x] = new + for (y, x) in green: + if (y, x) in blue or (y, x) in blink_green: + continue + new = f"{colors.GREEN}{mx[y][x]}{colors.ENDC}" + mx[y][x] = new + for (y, x) in blue: + if (y, x) in blink_green: + continue + new = f"{colors.BLUE}{mx[y][x]}{colors.ENDC}" + mx[y][x] = new + for (y, x) in blink_green: + new = f"{colors.BLINK}{colors.GREEN}{mx[y][x]}{colors.ENDC}" + mx[y][x] = new + print(ppmx(mx, pad=False, space=True, zero="0")) + + +def draw_shape_at(mx, row, col, shape=None, value=1): + if shape is None: + raise Exception("Please provide a list of coordinate offsets from Y,X to draw") + for y,x in shape: + mx[row+y][col+x] = value + + +def collision_at(mx, row, col, shape=None): + if shape is None: + raise Exception("Please provide a list of coordinate offsets from Y,X to draw") + for y,x in shape: + if mx[row+y][col+x] != 0: + return True + return False + +def out_of_bounds(mx, row, col, shape=None): + + if shape is None: + raise Exception("Please provide a list of coordinate offsets from Y,X to draw") + height, width = get_size(mx) + for y,x in shape: + if row+y > height-1: + return True + if col+x >= width: + return True + if col+x < 0: + return True + return False + + +def spiral_generator(width, height): + k = 0 + l = 0 + m = height + n = width + + ''' k - starting row index + m - ending row index + l - starting column index + n - ending column index + i - iterator ''' + + while (k < m and l < n): + + # Print the first row from + # the remaining rows + for i in range(l, n): + yield (i,k) + #print(a[k][i], end=" ") + + k += 1 + + # Print the last column from + # the remaining columns + for i in range(k, m): + yield (n-1,i) + #print(a[i][n - 1], end=" ") + + n -= 1 + + # Print the last row from + # the remaining rows + if (k < m): + + for i in range(n - 1, (l - 1), -1): + #print(a[m - 1][i], end=" ") + yield (i, m-1) + + m -= 1 + + # Print the first column from + # the remaining columns + if (l < n): + for i in range(m - 1, k - 1, -1): + #print(a[i][l], end=" ") + yield (l,i) + + l += 1 + diff --git a/2023/python/shared.py b/2023/python/shared.py new file mode 100644 index 0000000..3ad982a --- /dev/null +++ b/2023/python/shared.py @@ -0,0 +1,161 @@ +from contextlib import contextmanager +from timeit import default_timer +from pathlib import Path +import cProfile +import functools +import pstats + + +def profile(func): + @functools.wraps(func) + def inner(*args, **kwargs): + profiler = cProfile.Profile() + profiler.enable() + try: + retval = func(*args, **kwargs) + finally: + profiler.disable() + with open("profile.out", "w") as profile_file: + stats = pstats.Stats(profiler, stream=profile_file) + stats.print_stats() + return retval + + return inner + + +spl = lambda y: [int(w) for w in y] + + +def minmax(l): + return min(l), max(l) + + +def load_rows(day): + return [row for row in load(day)] + + +def load(day): + path = Path(get_fname(day)) + return path.read_text().rstrip().split("\n") + + +def get_fname(day: int) -> str: + import sys + + if sys.argv[-1] == "--sample": + return f"../samples/day{day:02}.txt" + else: + return f"../full/day{day:02}.txt" + + +############# +def load_char_matrix(f): + my_file = [] + for line in f: + my_file.append(line.rstrip()) + return [list(x) for x in my_file] + + +def load_file_char_matrix(name): + with open(name, "r") as f: + return load_char_matrix(f) + + +def load_int_matrix(f): + my_file = [] + for line in f: + my_file.append(line.rstrip()) + return [list(map(int, x)) for x in my_file] + + +def load_file_int_matrix(name): + with open(name, "r") as f: + return load_int_matrix(f) + + +def load_word_matrix(f): + my_file = [] + for line in f: + my_file.append(line.rstrip()) + return [x.split(" ") for x in my_file] + + +def load_file_word_matrix(name): + with open(name, "r") as f: + return load_word_matrix(f) + + +############# + + +def rotate(WHAT, times=1): + what = WHAT + for x in range(times): + what = list(zip(*what[::-1])) + return what + + +@contextmanager +def elapsed_timer(): + start = default_timer() + elapser = lambda: default_timer() - start + yield lambda: elapser() + end = default_timer() + elapser = lambda: end - start + + + + +def render_cubes(maxX,maxY,maxZ, my_cubes): + from mpl_toolkits.mplot3d import Axes3D + import numpy as np + import matplotlib.pyplot as plt + from mpl_toolkits.mplot3d.art3d import Poly3DCollection + + def cuboid_data(o, size=(1,1,1)): + X = [[[0, 1, 0], [0, 0, 0], [1, 0, 0], [1, 1, 0]], + [[0, 0, 0], [0, 0, 1], [1, 0, 1], [1, 0, 0]], + [[1, 0, 1], [1, 0, 0], [1, 1, 0], [1, 1, 1]], + [[0, 0, 1], [0, 0, 0], [0, 1, 0], [0, 1, 1]], + [[0, 1, 0], [0, 1, 1], [1, 1, 1], [1, 1, 0]], + [[0, 1, 1], [0, 0, 1], [1, 0, 1], [1, 1, 1]]] + X = np.array(X).astype(float) + for i in range(3): + X[:,:,i] *= size[i] + X += np.array(o) + return X + + def plotCubeAt(positions,sizes=None,colors=None, **kwargs): + if not isinstance(colors,(list,np.ndarray)): colors=["C0"]*len(positions) + if not isinstance(sizes,(list,np.ndarray)): sizes=[(1,1,1)]*len(positions) + g = [] + for p,s,c in zip(positions,sizes,colors): + g.append( cuboid_data(p, size=s) ) + return Poly3DCollection(np.concatenate(g), + facecolors=np.repeat(colors,6, axis=0), **kwargs) + + N1 = maxX + N2 = maxY + N3 = maxZ + ma = np.random.choice([0,1], size=(N1,N2,N3), p=[0.99, 0.01]) + x,y,z = np.indices((N1,N2,N3))-.5 + #positions = np.c_[x[ma==1],y[ma==1],z[ma==1]] + positions = np.c_[my_cubes] + colors= np.random.rand(len(positions),3) + + fig = plt.figure() + ax = fig.add_subplot(projection='3d') + ax.set_aspect('equal') + + pc = plotCubeAt(positions, colors=colors,edgecolor="k") + ax.add_collection3d(pc) + + ax.set_xlim([0,maxX]) + ax.set_ylim([0,maxY]) + ax.set_zlim([0,maxZ]) + #plotMatrix(ax, ma) + #ax.voxels(ma, edgecolor="k") + + plt.show() + + diff --git a/2023/samples/day01.part1.txt b/2023/samples/day01.part1.txt new file mode 100644 index 0000000..7bbc69a --- /dev/null +++ b/2023/samples/day01.part1.txt @@ -0,0 +1,4 @@ +1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet diff --git a/2023/samples/day01.txt b/2023/samples/day01.txt new file mode 100644 index 0000000..41aa89c --- /dev/null +++ b/2023/samples/day01.txt @@ -0,0 +1,7 @@ +two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen diff --git a/2023/samples/day02.txt b/2023/samples/day02.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day03.txt b/2023/samples/day03.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day04.txt b/2023/samples/day04.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day05.txt b/2023/samples/day05.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day06.txt b/2023/samples/day06.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day07.txt b/2023/samples/day07.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day08.txt b/2023/samples/day08.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day09.txt b/2023/samples/day09.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day10.txt b/2023/samples/day10.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day11.txt b/2023/samples/day11.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day12.txt b/2023/samples/day12.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day13.txt b/2023/samples/day13.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day14.txt b/2023/samples/day14.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day15.txt b/2023/samples/day15.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day16.txt b/2023/samples/day16.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day17.txt b/2023/samples/day17.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day18.txt b/2023/samples/day18.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day19.txt b/2023/samples/day19.txt new file mode 100644 index 0000000..e69de29 diff --git a/2023/samples/day20.txt b/2023/samples/day20.txt new file mode 100644 index 0000000..e69de29