From 634812126b04752ce18c14c17ba2482edba6ccd1 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Fri, 1 Dec 2023 10:05:28 -0500 Subject: [PATCH] Day 1 of AoC 2023 --- 2023/Cargo.lock | 7 + 2023/Cargo.toml | 8 + 2023/data/day1.txt | 1000 ++++++++++++++++++++++++++++++++++++++++++++ 2023/src/day1.rs | 180 ++++++++ 2023/src/main.rs | 13 + flake.lock | 57 +-- flake.nix | 17 +- rust-toolchain | 3 + 8 files changed, 1222 insertions(+), 63 deletions(-) create mode 100644 2023/Cargo.lock create mode 100644 2023/Cargo.toml create mode 100644 2023/data/day1.txt create mode 100644 2023/src/day1.rs create mode 100644 2023/src/main.rs create mode 100644 rust-toolchain diff --git a/2023/Cargo.lock b/2023/Cargo.lock new file mode 100644 index 0000000..e70b6ec --- /dev/null +++ b/2023/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aoc-2023" +version = "0.1.0" diff --git a/2023/Cargo.toml b/2023/Cargo.toml new file mode 100644 index 0000000..f6c0d46 --- /dev/null +++ b/2023/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "aoc-2023" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/2023/data/day1.txt b/2023/data/day1.txt new file mode 100644 index 0000000..bb9803e --- /dev/null +++ b/2023/data/day1.txt @@ -0,0 +1,1000 @@ +twovgtprdzcjjzkq3ffsbcblnpq +two8sixbmrmqzrrb1seven +9964pfxmmr474 +46one +7fvfourgkfkkbloneeightdrfscspgkdrmzzt1 +15two6six +htxxfmfd7nb +sixfivesixeight4pfsgxvn9sfjfk5 +pmjjpggvhkrq2 +tvbrkhlxdsnine65 +four5gkrptqninenbdvffour1z +foursgnlxmjtcrrfour7 +3onetwogkhmllzvrsqzhhnkvdg +nineninegxknqzpsix28 +1seven85189mv +gtwonejcncdlhpsxjrxnmpvfgtdrcdtd2nm +1ninemxzntjptl +qcmqfour2onesgplvgzkdltqtvzhtb1 +seventhreerxqvgkzqhfxfdhnp628zxtbjklkpdtwo +fjdsgcsqppzdthreefour3one3lvmpm +sixsevenfivefourxf4mzhmkztwonepzt +nineninesixskjkbhx6nineoneightj +four6nzqxhhnrg +86fiveone9dhrkkh6 +8ninetvnsrcsbpn +two43one +8vfvbrnclnmthree8onetwoeightthree +one2czxjgbzsn46ktj8twones +qfnlfivemqninextzppkfkb8 +ntvcmxsevengxdtc3five +8lsfkbbxkscc +seven5817smvjfpdktwo6mdfngz +92hqxbchfpnine +tvxbltz53oneninethreeonek9 +hvvjhd1 +six1six7sevensixqcvhsfour7 +seventwo2 +2svpbhrlhfjhbkf3fourvvspkfmbvztmtpcxndfnine9 +fivefour42 +sixvstzdtfive3qzmbbx +rfcxmthzlgxgrmjncszdvlnp6 +lhlncfjlhrqrfzr1 +cqnkmtfj5 +tctfngvrxljlt53pntbcfrftjpjvzqbqxh +6fgcdfive +4834sevenvssix1eight +rpxcthbpmhgrcxk4 +threecthhnine781 +pppqkscmthreeseven1sixfive +2tgrmvxpthree6 +7ckxjmlpkqqqjtfiveeightbmmdoneighttnv +six2two +lsshzhtdfour24 +mrjjgzsb92fivetwoxh3 +5fourcqhk3two85fiveeight +lsxpkxfmq97one +b87twosshtxkkplq5zkrrqcmfn +threeqsnd64hthreeldbtfkqpbqpdlmtwo +eight2one +14r +71fourzrmsevenseven9 +threesixmmcjzzml4 +stnmbsix41 +cztnnflpcl4txplfour +five6six4kxv +5oneqmmbnvgvbq6vsncbrjrsix7eightpzkhvrjz +kflckfgxfeightlr37fourfiveseven +9three7three +rkxbqnine7onevvqgzcvvjthreendkddfournine +fzzfstwo44vm +19648 +7fivesixhdxhlgmv9 +six9hzlctfiveonefour +66eightthree4nine +jcgk8three +tbctwonefive2eightsixbntmjceight +ninemrqkzsevengvq6 +rsmmpmrlmq92fourfour453four +6eightbmjhnpbgnccfninefonenineglkfgp +8onefive7kn +eightrgzfdksevenftbvkt455oneightnl +3vxtwogxpdhjmqskjc +shzvnlgvvvthreenkv14eightbcmjd +2sevenlbq +1zfjpz1mdfourstvj7zpfxxlqf +twogm22trvplbsk29rbjtvctqr +twoqpgcbskdgh2tktbbpnzll7twoxljpdhthree +5nineeight6 +936 +218ptffour +1clztnnsix1 +bsevengsxbpjmbg5eight +1cpeighteightpb +vrlnveight2twopxmtwo +fgrjr8six +5sevenspppgjtxbtqlzt +5sixczhncsix2qcqsevenfive4 +kgcdpqclsggzm79nine +eighteightone6sevensixthree +92eight7plhftxkntl1two +5dqrhhqrrgmvrqznbgx4three3 +twoone953cdkm5stzdbdh +heightwothreennzljtptwo94 +6sevensevenfoursix5nine +cnbslkngtk9five58xpqvgjpqrnpjnzbk +onebrcg1bnfivekftnzpclqxvhchloneightzrn +four855dpknm +4hkdseventggkffhrkvsixcrsqjsix9 +8seventwo +two9sixthree9cdrmqntmcv +525tg4h +five7kxrlmq1bzhdmhtgglmvzrtfbqqd3 +bnbbsbhlcbktsqlpq69ninesfxhq +gndxnlmnrmnk29qkfxfoursnnbvjtq +5bzppjrgcpk +2three79pmgtcgmtdf2fjh +sixmmpbmtznseven62 +4rrm +ztlthreesix28ninesix +j7fourfourfbrlxplk +zjhrqtqsix1 +4three6hhndrlszfrgphcbonenxfive +jmg8hfsxfsvdxz3four7jfbczjmdhbpn +39ptfzqjfpnpxrnf7eight +three6jrcrgpfxg8vxgk8 +57kvbczxn5eightfour +8xbdbrbpjp +sixtrhhl2tktvvmkffl5 +three6fgsjtmnine54sm5k +ninenine3stfpft2nine +one61onenrhmtwos +pzdq8 +pltd9sjdkrscxr25 +dzsldkmzd1 +vlvpfmz24sevenshcrvx389one +1rfvlnmfkdbmdjj +sixbzzbftqggn8zggtbcd +hzxzjhkvd5twofivedxfdlrdeighttwo +six9nlgcdznskrsb +sixrxkfhvsjxzbt4fivenineninenine +dsbmqpgmf8nine634two +fourknfzpthpf1 +two9twovbmldd +5zgnnrxtwo2two2 +fivezfvzfdxkmrbvtpdhqbmdhcthreedvlstmq28 +ppfqqq75seven954 +sgtjpsix3 +twospnc9cnchkzthreegj +3eightwoqs +goneightghmkgksqfk2two2six +sixthree6bjzpqlsbgq2rkbffxtmprpddkxv +rkv43 +bzfnbq8onefourthree4 +3mqvr +fiveninefflpllcqzonejqqbtwofive43 +tvoneightfour3three5 +mvhlv6bzbjggrsvvxh4dfcpmrnhnq4 +fcrsmfmpnmkfs3fivekblglhqmvfourchc7 +svfmfbdrgd81one4 +mf7threetwo8nine1 +qngfr4gnnxbszqzsixp +px5gfx7two5seven9 +4gp +8lxkgvpzxch6 +3mdgqrvtgnthqnhpxteightfour +onethree899btbpjnxxjhone +fnjdzx5vrzc +four5twofour +9fivetwo2 +threezlpsdhxvdlfpsvkxxnnine3 +hvnnq9two2fourpdjv +bvjkdg9four1 +2412 +threethreeszmhdndctj1eight8lcqtwo3 +cdnmjmxqrz6vrkkxtfour8cc +njldrqggdnfsix5 +9csxcksh6three697 +92four2sr32 +3jdpqdjjct44oneone75pjgkgv +576sreighttwosixxzqmj7 +twoscdxdlfddmfive54 +ninefiveznine33 +threenffnvx3 +916tpsgsxmtml8 +6five3 +fdztvpctnr5dmbjnrjslr +16four +4oneightk +three5fouronenm +threezrksvlbdb891zfbbcdrbpd7 +five821ndfftdbmbr3nine +ninehvdxftmgcvnkrlrvmmbb4nine +xkkzphgfv1two +3pm +ninetwobtjxdvnhv12 +fiverbkmfbx8fiveeightksjzphkrj23rdlrtnb +kseightwo2fivesix +5snpchthree3 +71oneone +6frxncksfxboneftdpvmnfdfxreighthrmnqc8 +two48mhgdtlp246four3 +993three8 +threenine7twohbmcrpd +9bpdccqbts +kptwonejntgcdqdfffour4twobvtxnhqkl7 +1637sevenfour +soneight6lbcrzdmhltpbkbjfivechxzfrqqgfeight +99five3hjvjrdmgl +qncqlreighthkfmbbfqx87five3 +7jqkdsfour +ninemmvcxlkcrg1 +mkdhgzcvmseven3onesnkhtxbgf7threestvjqn +nttgqsmsl4five1eighttwo9zg +one2ninefour5 +bdfbveightseven1lcrshdgxznineeight +qsnvsonezqhsjmfive9one +6kvdrgkgznf1cmklmxgnine6 +xkmzzdpknl661 +ninefoursix7gnbmzd37 +mmxmfnsrmt2bnhkmftxnjsix +fmhsrdtnrxlqgjttlgvmqxgzpl756sixllmdvblrvrrzkqgb +7xmppbvd976dqt87 +fourzdctfglzzf1xdbfmrbfeightwor +8thncgqzvr989lthreeseven +5qmrzeight169 +4qgvkmninegcsdgcthsp62onehczjhdxcgm +25tlppkmctwo2 +668four4 +rjbxtvfktchflstwo639one4 +seven6eight4onehfztk +five53 +nine33threethree3pznjbtxjmrrxm +19six +fivethreefivegxcqflqhjrn3fivehcn +vpbntqnpkjfninesix6341 +7eightb7 +bktffkqsx6fzvpnjhk +38jrjprtwo628 +77tplflrp7 +4one9one6 +pkdhkbxrbshccxgknrjgseven44 +49rthxdvlmeight +5twodhkpfn1 +znine2fbsmeighttwo7 +5ninexvmg +dbjbfmqtkp66 +mdsrdjdnxkzr3xfm +two9twofive3 +9kfivetg2five18 +6fivenine2 +2dlgpxsq7sixone6 +tnqxgjbnc9bhqbgtwodxssml +18sixcjthreetdtprgsix +65sevenfive9nine4seven +nine34fiveqjdqc +threetzvxrb5vspdhrmjcnhtrzkqhd4 +67nine8jrxt39 +443oneklzsrtwo4tbbvxblk +xp7fourseven +ktsrninemlldztwo5ghqfgh55 +five6eighteight7mtstgjlqmngzonetwonec +rmfourseventwothreedjtvf9 +rlsgqhhvcdvthreekzjdssslmsixfour5rxk5 +sgnfjqm4fivefiveone87nine +6twoonefive +sevenrftrnqrjs1 +bcfgjklzfbnineninefivesrpcqtwo4 +threek7seven1fxslmvnhmffqqvbfbhlceight +sixxzqz9fivethjgdv2 +nineonefivesixtcrjd5 +5645ptsjfrszgr8 +1threezkpgczxr8four3oneqm +tvlfrfcnlc56eight8ninesix7seven +7clvmrdvdgjg +7mcstlktwo +dlxlpchr3eight +3ninelrzgkhx85 +jlkqzonefourrvlptlxxgrthree4six +rxhpprsqtd982t +six4671nineonesix9 +eightsixtm9vngskjglgvrbsqgcmxczbqqvxqxfj +vxfmc1six1ninesixnine +39fivesixthreevmpm4 +xllclztxcxjskgfourlvggrvr25fourthree9 +31sevensixninedpfrvvfftc +three64ctshdpcsfdjth95 +fourgcqf8sixfivepsrdqvrld +5nine1qldrqhvfour +5three1three +6hjbgdqjtlppzoneninesevenqlmvgkq +eight1three6sixthree5two9 +17141oner +five1two7 +sxcfxblvfbtdtlkdpnineztnsfdkmeightvrr7fivejj +eight183krc8nkqk +sixthree38fourkgfbbv2sixsix +922threeeight4moneightsm +3threefive8bdzjs +onechvnhrfthreebqfive9 +8sixgkvzgnfkjrrxrxvbvgvx +meightwo1dnbbpzrxftwo8 +253lqt1bzfpqznz +klsgclc549rbksgrbbh56 +3xksqcrhdsthree +55nxbjvps3nbmf +7qzzfourtwo1688 +h5skqsrnnpxdone5fivefourkffrsblv +3fourfive2 +25stdpqvgmzg9qksix5three +fivenxhkvbscrxx1j4 +dtszrbcgpgxbh1 +fivefvrp159three +68mdjsggnbtwokmthtwo286 +xtwone7bkhjqkmmdkxvqtxfkpmckj5 +btwonetjkkdfqphr2gkknfz7one +ninejgnxcchjqsevennvdjvttnqqsix6 +395seveneight +lfrsoneoneeightfour6 +four9prvhcqdnrgjl +qhbkninefive73six8 +sixkqjtrs1hrmnt +5lmctnqtqc49eightnt +sixghthgcnpfeightseventwo3 +vvvjbvnjfeight41nine +9gkxpcrql9three4 +65seven4eightmjnh2gbjjstdgb +8four68seventhree +19924nine1lxnfzgt +fgjtbsfour4nine4vqfznznqxnsevenvzn +fiveone9bzshjmdvdsixxknhmmqskone8 +xqjzgmdmnfivefourthreemmksmdsix6cct +eightklfnlkb9 +rmtsdblmcghszsfgd66seven1bct +twoseven6 +psbfmmmrppdfm5ninetwosixnine +rkcgdnslc9pjtqvgdmbvpkbbksxgr +mxjpns69 +rspjpcv4fourthreesixfourninevlfive +2dgjgdn +66five8qxeight +five93 +six7twovssixsixztrmfdrrvgqtdhmh7 +32sqltqgoneightd +4five8tns1six +277 +pmrzrckf6 +8rglvpcttwo1twofive +fivethree644hrphp +fdpjb6 +dfkpmgxfgfmtklbffk4sevenfive +nhqfpnvpsqpffour6neightfour +threeseven9eight67three8five +txttqnnineonefiveninesixlbscpqp1 +three2sixtwotwo7smkmq5 +8bjzjrnpspnine5 +5three659fourfour +qrdrk7fouroneseven +three7threevhct +mpjpgfbt8five6fqjbghvbpcnine +7zonesevenzmlvfvzn +2hzldqdntffxhfpxlghf6threeninejrxngnjq +dfppvqcvthreessnnm65tqtn +56nine75rdkxdcmj +8twozvjkdltz4sevensixfive6 +vzpzllmbghcccksevenjgjghqjr98 +fgjsgxlh48sixg3three8 +4eightfbppqltgxttoneoneseven3 +six1eightddcthzd +fiveggljcppdeightnine5hsbfrtninenine +2xrdtzfnhpvpgone +982 +two7nine7eightnine4 +one431 +eight9fmbfqxgzlskgjrrksr8six +9zhvdllsszd +4pnkpxrgltkdbztlnz2 +4ninebkh6ninefiveh +five9ninevrzxhfnggfourfoursevensixlncsfdvrz +rqhjjxzeightnineseven7fnmbkrtqgr +8xfmqdone +pnszhd1trqb71gfhpjpq +9htfkgbxlht +sevenoneqgx29three5six +fourdlscbpbpb9four5jbdjzqqdthreerhqdsbb +five31sevennbmrbhtthreebzqxvthree +one4c +three38183threesix +6rtdclcbfbbdbeight1 +2one8xdeight +2sixsixtwo +nine3pcjthmlmtljkrzxcdxkbmgzneightzcmtwohpdpkvqg +9two81qlhsrnfpdksdkd +threejrgxc4seven26njlmtbheightwodjh +lrjzhghhpk342threeninejskdnjjltt6 +46threegj +ninedgpkqblftq2b3four +3951sixssgmjj3 +8jteight4 +three6mdvfkgrxcjmfoureightfour3 +hvbf28 +9fournine713six3 +four1seven +763twoseventwonine4 +ctpfmnsvcthree9sevencbqtjc3 +sevensqdhvxd36 +fourninergfmdxpdbt1ninefour +2kptonesixzpqrsqzhv +h4qcscfxfctjbqnff1sevengxvjjc3 +d8cnjksdf +hzcgnine35fcbxtlg8rjhzbjfkv +jdvoneightdpfvzvp758fourfour +four27jhrgqnrjnkzffour5 +fivetwoszrxz2fzfrbgqntjf +onergnqpl3 +ccfqnc5twothreefoureight +grgsgxsevenkvzfjppnzq2sztcfive +9two94onesix +nine7seven7 +eight36 +plgsevenvfljnqvtfq5two +threethxdbnz49two2vdxbpqtpb +cf9fkrbrvjhssptthree +one5lrcn3klrcphllmz9 +onesix6seven8tzgfdbm +964khvfxtrljs88 +trszhb48fmseven +tdfxvnhrzv8threesevenkgp +ninegnmjxzbtcb32four9mlpkbfqdxdkoneightg +sixnineeightnhlqfslb2v +one83fc7zs +pxfkljdbdqqqvnrfivefoursg5nine +2onevh +1fgjrsdlgnbmsbzsevenfive +3nine87pmsqqntwojtnrksdtwo +two59kltcxhzszhdtwo +6451 +sevenzscjhgpfgsseven7threeseven4threedlbtxtcvl +eighteight8sfsvhbkf9jgfrddx +qlvdplcqtrcj2eight4 +sixbcpxtjt4onetwothree69 +91fourrbblcl +twozvqbsx4 +twogfh73 +onesixljjrlonethree3rxtwofive +onefour62 +b7vfplpqnine5 +67dgbmmjsevenfivedktq +7foureighttwo4 +sevenctctvfg51tsbzqgcvpvslqb +mjkeightwo7eightsb6one5xzsix8 +151dht66 +93tkbs +29two +foursixtwo5gprqslprxkrbfbmsl1six5 +one3six3 +three66rbh82bgtfzsfrkhrv +2sixfivethreefiveseven +fcjttg4onesixtwofive +15seven54 +5kjdkr9htl +gclrsklbvkfbdcb9seventvdtdmmmksh52xkxtpmfpvk +spone7eight5xzjrlxrnzjtqgpdcgrsjn +vs3fourdkdlhx7rb +9ldxtdk3 +4dppnthreetwodvkhjjrqh1zbqxntvtxgchv1 +1sevenmsdrjgqfivevphqmxzghktwo6fdvkvqhj +tbptrcvxhs9qcdxcpvp +8five2ssrrhgtxfone +3clvbm2g961 +four2onegkhbdfive5vxvxvtxglg6hxrtlhzjh +kfhcmflznrg9qnkkxqcsm2vqqtrdg8tjkshzpnddvd +eighttwojfktjcrqthreepssfour39 +359nine2fivevvscbvggjhbnnzqtxfsbpb +vvshjlcfqt6qjvfjsix2tgsjbdxgppq1jmr +ninehhmeightcvqskvjptz2kdnhpptvkz54 +39threefourndztxcl +sevenfive7 +csmmpzfsix41 +9cgqxtpdxt2 +3mpzvlxrzvhtj +fourkqhzsjjjvx3six1 +52one +nineltplrl8tfzqmnqeight +sixfourdqrfvrvbvfzzgb6 +mqnxglzjk6qqhzksklvsmthreesixmvhmhbdkqpnxcsgvcsl +65 +zqconeone85three +rxnhdflsqdqglxdmfxlxponeseven4one +88nkgcglftwodfxfhzxbqdpfrqmtwonenf +jzoneight9htkkpszpcqvkmlvl +388xnq +9xhlrqnkjpthreedfknpmqqtwo +4onemfzjfvmhhfive3two5pjdcf +djqjglztxs5nineeight8jdzone +four35ninefourfivethreecnhntp8 +gxqxl6fourlfdtndgdql +fivenine6 +1pqctbpbbgrmgqfqbzbjjt6 +xzvjjfnfr28jblqseight +ctwone23 +6sevenqjtwo +8nineplhlmsgjvs1 +lmjgmltfivenine9 +8gxnnnjonesixtwotwo1 +2seven678cdxhkflhj3eightthree +djzninefour3one +vbqhjjhpzg86rkzdjzfj +eight1twotthreeqqlr +bkxseventhreezcjvdkxzksxrznp6four8 +five77xcvphzcnlfbgbxnqbhfrldg +71qxqdncxdjsix +eight6one6jnpspgmhngzrfneightzdnrdhj +xb9skhpnfjsmq +jxgtk618fiveone1zr +8dkdnbfr +3llplnp4dzdxfhbvbn7two +eighttcgrbhrspktwo6eightddxhqqbprrf +eight2mpmzsevenrcbmsqg2cxjvmblnqbqdjsl +seventwo54 +koneightsix22three +zdsnjr5vxrhkthkr8qmddrzclmrkprmvbll +fbkmfxncztwohjbfgkhgvcdkrpnc5 +ksprkgxkjnineseven3fivebjpqhrmbdtwo +fourpss5 +1three9fbnnrjcgllkvcs6 +oneone9kjchnfsv9ffcdspfive54 +26ninejctplmsgb +9ftfjrmvjblzqqmrdczpone3bphtmmkm +7lpssdtbc67mhnthree9cndbsthree +fourfour49four +nineeight8bzeight +128zpqftnxnqz2threettrhscsll +1xdtxcg4tkxtsnl +hmxbjczvgmcrd9mqsfivefourninethree +5hseveneighttwomgxmlmskr8 +zdtbtszzkbk5 +eight5nine6xthreefour +9rbfcnjztthree4v9vn +voneightqdtnrtc4 +86cnzxs2three5 +eight9seventhree +tjmrjgcfldqtbrvnzzxshxkrs3onefour +2rxplslzcglskjxgthk76cczdbxrp +sevenpdvsbhkknxqkqxfcz6bhmkxmhdbvhcvvhpmv49 +three1twotwopr2lctfjb +zrbrqmh87dmxzmtfvthreelsleight +34dcnd8eightwombx +two9xnqtcfgq8tsqzvd3three +nine5fq3 +eightsixfivemtcgzlbkheight4 +qlspgfndmx5twobtjgzgvzmcone +5zlldrzrffgggtwo648 +seventbqtkpfivel6 +hjqbmfnnqzmf4 +fiveqhdfsnjvqtwo6two +jftwone7 +4twolqvglgxcc +twoqjmgjtrrjjt1eightcpj +eight9sevenmlkpsbzmtnhdrkbmj +trrpdninesix8oneqxtrzf +5sixtsxqdbnczhbvmfkvkc +tvbf2 +sixtwonjssgpljqrxhlstfx4xbhqzlqktsixfour +kfxccb45tzsftztxjhgnxqsxknl29 +tworjdcgsgvsix6 +eightjbqfive26gfspjh3nine +2sqhleight7cfkhzrsevensevenfive +kzpzjcrl98sfive +sevenrsgtnine4pbgvrbcpf8 +25q3qkcxlvhrxdonednbtcrrvjlnngq +twothree4lffpxvfcgqrkvdgzdsdjxjsh +seventhree34seventwofive9ckm +three25skfkvqdmbmsixxgqx +three1eightthreesix4 +threeftjlv9 +6spbhfckxcdrxlcg6hxcfive6five +8drbfjrgzvs834slzhsbgrjm2seventwo +sixsevenfmrvpqbgx4ncrmvfkjx62 +lqfsslkmstwo7rgnqeightthreetnlnonehszkrghlnt +5onethreebxxfstvd +djchrbjcrddcqfourmnninesevenrdlpfxthr2one +three3threeoneninepcrjr1 +twothreernxmhmtbn2fourtccrqhqs +lzzdpfourtwo1six +two3one3 +zzcnprtjdr22286 +seven5qjlfrhj7seven8 +seven99 +mtztq6one37oneeight +mrfcssmzxpvcz2sevenfourfivelpzqkvvdxmmpmxqshskfnh +nine8rtx71 +1llzpvcdgmvoneonepksninefourthree +gbbvkcfive18two8twonineseven +2fivenztsix2nine +gjqnnr422seven4ppbsqdbpcfour +fourtwo5one7qfgpmmphdtl +pglzjrr4fivebclpf +slrrcqxxhtwoeightseven6 +dnknxxkbjplrkjone2threesix9 +htctqnkcmfqdxrzd9eight9seveneight +8sevenfiveninermlrrzpcdxkjkczhgpx6eightone +eighthnfxhrtssbmfxv6v +6fp539 +sixzmsfqjzpvxjkhfqcrbss7xgg15 +nine5ninevddknzczpxgzjx +jbcsf3 +jjbstlskzxc5nine +jlrvgcbch7tnpfjnczdsrgddrseven156fvdmfhtl +one89 +three52sevenlxxskf7gxh3gb +eighttwo59mqzdlqjdkkxgjhnktwoone +519six +1onemneightsixdlqx7 +7fgszpqcj +sbfjtrfvnv6four +qtwonedvkninercj8 +ntrnzldltrvtcsh8eight77sprgsvfdljthreecndckrzmjl +gtspn2 +54six6mkjznlb +sevenonethree3sbpjqgltv +four8two +xdzrskv3974mgvjlhzbkddhcxzzxv +6three1mtlxshtxfpnine +14threeseven6 +37threeonefpfgmz9 +three3sevensixeightfive1nkjtndgrd +2dsmr7qhmnrgbsrvjmsbctwovb +gkdsnnqzlzdvcgthree3fivedzvpcfive6one +3vkftsclsxtxmsjeight +sglkcnzgz4mnhgblxqgdv69 +tpcjb4one73s4 +sevenrvhhxjcfqgs32six1pjvltwo +8zmktmxkbc5mpgrtnxmnp35fttpmdbhfm +1sevengeight +hghs1sixvvjpmlcponethree8kckgkf +gkbpflqvh1cbddlvdkzhfmzcfourkmckngsevenxkjknplzv +5sevenfk5qgfshtqseven155 +dfjdtxjxb8fivefivebjtbggkdlpxlmnrcdt4jrrpnbtvlthrhmczn +2fivefivejxhh6 +41threehtwo4nhzdn2 +2fzngnxvvpjrqxk6 +53sdthreeninexrfone +6qmrthlzgqeightrzrdglxvscgr +snkmhszcbmthree5threejsvkpkknpeighthbv +cmgb9seveneight +5djnine3bcffxgjbrhxbfhgthxb +1flqjgsf2ms +fivefive7onefour +threeeightksmhj94jvfvqrsgqrsevenj +jttgbfmh9468ddshrxnjthsix3 +25four +9sixseventhreefiveninefive +eight5twoqrfgpkbdfc3qxfmchrjx8kpp +nineftnvllx1rjzkkt +gmeightwothree1fgfivejldgmt +nine966fivethreeninecpmgsxsxz +77bfhphxczdg2eight +89hcgjjtchsix +1onexps1 +3fourkgm +hjgnbninevxdtpnct7bmstnczzteight23 +twoone1qt8 +43744 +fourtfgn2 +sixppztkbvllkltbs51xknnfive +tqxoneight5 +twong3zdrbpqnb +fivebcrxk198three +435sfddjvfg56vkddkzhhj3 +qcnhlbzmbld2fivebsix +zfsrtwothree8 +nineeightfivetwomcjm2seven1 +3gbnxlzxhvzzgfjjhf44fgbccpthhnkpht +3ccmrkbfour68ninetwonebz +sevenrccgdjrqj9one +fourzgdfbsnlb66txclxgp7 +jmzlbtgbtl8three +6nine32pr +sixffcsmhlfiveklbmgj8nine +psmjrt65tppjqeightzqvglglnine1seven +fourninehhzh8seventwoone +48two2vzbrl +mdlzptrcsix3three9 +sevenlgr3t +7sevenpphjhvdhkheightwojv +seven3756 +four85 +4twoonettmxjncsqmgsrxsf +fivesix6twofvzqxpphzmlkj +eight1twojrzspbfbzkftwo +5eightthree5 +31ninecjnsevenjvbsvpphpxxkcnine9 +nine5vnine486vrhbkgl +sevennineeight97qpdlfbskz7sfbtm +onernqbxt8twoone +gftjrbmkmngtshchbgfc1nvvt5 +four5dgvsixzhlxnnmjhkhkljcfdpeight3 +ttmfdxhd3ninekzbtsixnfmvfour +8pfkhxhmh8xkghgdk +nhs4threemxjpbgsix1s +ghtwoz1 +sixdthree7vlfbpzcm1ndbbczvc +ninetwo183 +twofxsdt36fcthreethreeseven +7grvvzqhcbeightwopx +twoninevknhnkgdmhmlbxkeighttwonine4 +4fourdmclrghj2 +sevenmtgvr8four76fivekdqbsmmtq +klgpeight5sbknbhvsixfive6 +2vddxlzfpsrqsbsixlgrfnhone +jxfhlzcp6qctpqhb1 +eightd1162jsfcsplrctwogcpzlhqf +one4four7xx5 +threebqmzstphclb5fiveninethree +bkxfxxms6eightwoxz +nineeight4four +sdsgszdznng4sctkfiveszkdknqjf8 +vtzmnllvvhrcfdlxcxxlqvzst1 +htzxcxpvqj91sevenxrggdtjzbrgcv +ldcnbzstq4ktzdxgmcl +twohshbblseven4grzpdtfmjn13cmg +cktjnhdnine1three9mjqvnjtkseven +891ninesevenxbdjs +kxjpngdtwomxttdqcdkhdj686sixl +hsninefourcxfj3five3eight2 +6eightgkkr1one +658one +zqgrxfourfour8 +twobbnfkdtb9five21zcfiveoneightjgt +79jsm55twonine5 +eightftk2two +eightbjbvqscs5pvmb14lgvgfv +four4four +qmzheight5hgfourkgtqfhjfournine3 +twofzdqtvssx2 +1fivefivesixsevenone47 +xhrjffnine8 +oneseveneight72fqgzscqt5 +nine7fours58 +three2fourseventhree +35ninesix +qgjsrxgqb5 +fiveqghjjvjthree4eightqfgrhblkjtwo +9mvcm +96fourqzdsix +vbzqmmzbvrbxltvlfmcpfvnddmgsbb6four7onegn +three3qnlxmkhpctwosevenfourvmqmqlgfrsn +2seven5one2six15vgnqzpggn +sixljtvqzlh1 +45onesix +foursix44eightseventhree +djsix84rnx8z34 +1mkgthree8two9956 +psgnl6six5seventwoone +546cfgr2three +thtpczmkskptzn9pqzncp +31threeninesn7xhqvrsv +threehmjpvctfhnmhs57ninepzfvq +teightwothreesixdzqhvljk84nineninesevenb +gvptkx9rlsnmtwoonesqfxmzkv +7twojszdrxcxfour +3eight617npsbbrpkjtzsmeight +3sixqntvpttddsixninemtpb4 +1onefiveseven2fourseventwo6 +67foursevensixsix2 +one7qeightonehckxhxdfjjzsrdnj +38onehzjxg +4splxs1zfvfksevenkrzfive +fourfournkcj9 +1ljmbhcpttjnine +2xnvfpdgccxfivellztmtpnc +ljvlxplhxfsjqv6sevennine44nine +qdonefourlnrzrgthbt1 +twothreehvvhsxzqz1chvbcsxtll +82vmfjbvssmlgk2dbsljgvd3 +xzfbfmbbxfeightgfz3lvzpzbpmv1four +oneeightfd5ninetwo +ghddk7six7xqmglkvnqonesix +six1eight +7five5ptkbvvvfive +3hftgthreehcfrsnl1fivetwo +7six12onebhpz +mkqjv8bzdnt9sevenfourtwo +five3mzgqnm +sixtwocbjxlgvp1twoseven +dkfmbzmvxseven971 +bninetwojnsnkc7 +ninekzcpfive4five3phz3 +eight8143 +eightrzdmxzb8eight6 +5pdjm22ninej37two +fourtwo8fivetwosixthreetwo +ncttc71fourfivejpjzcgzpj4 +5882three8glcvgnfhscbtmnqmnh +ngxkxtwo9pltbbmxrknvjheighttwo53 +twoninenpqqqgsbsq3fjdk +eightsevensixhtsjvxjc8jxftgnptgqsixvcncglzlgq +sjxtcnt8gpeight7cbgffmgqksix +fdsn9threenineninetthree37 +19rrfdqtpmonetqjdcjtxlhkptccjn6mtztqhvvtqftbv +vrhprdjsfour28p4 +eightfiveeightninevdvnmbv58vrs +qdzhzrhlfl7hhxqzxqdxeight +svnbzgbhxjcx26xclfgs +5lcggbhzrmnknine83txffvcdonecrqvvjf +six5fpncsbbqbbcczcmbgrqmndxmrxloneone +1one6 +88gctsmp7eightrvshklprtm +xf874onehhcknx +sevenvvncrhvxjxnzsftkfhsktwo3eightfour +8ngprdqfour +98fmrxpxzzbrjpxzqdxmv +2zbxzsthreefivefhdbhvjjxv6btwonef +jzkjcvpn924qjcbr97h3twoneff +foursix3 +9pmtdjvrxjrponetjlxbdzbvrcjtc77 +52twoeight2fourh8 +kpzfztlzlkdprbmrhsjcxfzsbch31 +4fivebtfjmfive6seven +ccttxjmheight6twothreelnjmfoureightnvcvpmpc +6twoz1dzv95 +threelsmgdnxcsevenqr4xrtthzgkqxsrdssmjqv +fourgpvjxdg4qpvfivefive8nine +9mncmnhrclsq +9zjfmctz +pndgptggnsthree8xlcctvpsix6three +98npgrlkqmcninethree +fivexp6fourdpckhqpcxczrfbr +six2xdgsqdpsbmgftzvqhnjg +7ninepqheight2eight7g +2zrsevennlpcljnp +twoonethreevvpfp1jrhsevenfour +threebzmggv7bjm6cczkbsronetwo4 +three1foursgvfdrrqmk4two6 +onengzkkjsxsjlxxxthpd7xfcvkthreefour +sixnine5sixeighthlvmf +63gkmbsdc3fourmgrjhrlbqgcfxf +2bmldthree7skhhpxfonenineone +b6seven7 +seven39 +twoffxbsgpcxctmmvb4kdhn89 +seven1fmgtseven +ninegxbdmztzzbqq6lgcvsbhzplqt +7twoonev +24nine +tvjmbzlsjtrtdhdlvnffmcfoursix6sevenonebvq +5jpntjsthree1threetkbsh7 +sixone423fourqnczdxcpmsvjpzhl +33zdfourseven3 +77lltwo5nineseven7djjmdqkqfd +4xfnpfbtdl7 +two5ninejbrfrsbrsvzfivenineseventwo +89znjldjptdnfkeightkpcxdxcc3bkmfhtzkkh +qlkxd1rv44qlhhpjrninetwo +6l2rfscvcgdm7 +rhtsrbrmlnfvseven1eight23dd +7xcglznxrjzsmhqnkqjhbjqxnjpjx15six +fourfiveq1vcsnnsxkmrcjscn4sevendbbtjh +6qcvjplvnine91rfjk51 +jmdsgfxd5 +tlzpvtsvkdsixtwo95 +8threeeighthvhlqss +threetpxxlmfrhpf15 +4twoeightsix +rg8nvrtzxjvfddkeightwofzs +tggqninemk1 +mlchhftqkxtbhfpjsixnine817 +231rpkxcvcz5fcztnqskqtwo +five9hhrtmp9twosixthreeeightv +9threeschsm17 +hhreightfour171dtbmhzhhjb9fgbg +bhgp6 +fourztzlhdr2hbdlv8fivenine +fourseven8seven +eighttwo8eight +two12 +threenine76ndvklb +twoseven9jxfcthreecnrpvglksc +84fivehmf +jpgbtnrsb15eightgdtqmk +34two8eightbxqvc5nine +four4hsgjmtbfrvfivenine +threecfcx8ninefive3xone +cvhtlnlnhh71 +four9sevenonenine9ninejlgmtvxmxseven +vttchshfgfpdbmpmp338 +nfcdnhq6nineeight79 +rgltnqzrzfqdjsfrhzmfivetwogklxqdhzbjtwo5three +five3n69fiveninesixtwo +nfhheight12clcqcnpdbz6nineseven7 +eightgxtmstbthreedvrqllvp1ljqstbjdhcmbmbeight +two26four7three +6rtninethreefive +vhnqgdzzbxr9two7mdjzsx3lf +twothreepzxljpd6sixcmsxkcqkfive +6threesevensevenjzkcqthfivegmjvstrsix +five7fivetwofour +onesixseven767 +36onehxdpmcqxsfbfive +2hdvqrlhs5six +pjfcjrnjnk9four99nineskshccmmnvxzvhvqmcprkdqvhhk +4gronexqnzdfthreejgqt +kvrsixtwofive2 +eightfourone4hone +cgbjtdbvptworbcz3 +jpgmhfour1 +ngbgjhlstwokxc8onejlhczxvnjbrkqzdl +chbmqrz3fourthree +rgvmkpeightqdssbcgf9fivefive +5vgrscgshtbfgbljt5 +pxgq5kffxbdjgq5cjnpzfdt738six +meightsvfb47xcdfkhf5 +clzqdc4five1onexfxlxnltfourfour1 +fivesix3threeseven +tworgklxh1threefourcsrsbj5 +3fivepdppjlmmb6fkgrcbldbxsdjpbvbqgpj1nine +9clvlvsckdmjsbxzrmrhfour +fourlptwofqspctl913 +28foursevenrfjfive5qrfsl +gfhmkfln2jcqttonethreetbmcdhhvbnmqdgsbrrmpk8 +eight35qvkxtwo3fivevfive +26fivegpcqqsjr7five +three1seven4 +9fiveonevmxhtndtfzmnxvtjkmr51six +64vgrgtwofour +four9one +nxjtdt2three1three96lfzglzcfour +355six +9lvqslrvdrd8six +9threetwo35six +two57 +phpkcmfxvt7gphd1qglpmckhnj +sixthree1ffrdbsix4two +spbscvjfl8vvkpjkshkx3 +5nnjdbjj3 +bmmqrrkdcfbctmsk124eight9one +4rxdpvqlhn +seven13glpzfknqtxdqjq3qblzcjvx9 +8bnkbzszkxkrrfdmcstvfvp +nndndjrs1qd1421 +twovn9four8five +eightrc1 +ltjvtcqfzdfourseven8kvcx43 +vn6ninelr8 +2seven1 +7rldpqrfoureightthreesfhz11six +56fourkmvl6threegzfqnlrlz +8mkpcsnzmknmzpjppf8two7 +bzgvzcpkqxmbxcqsix4qjzt28eightwoj +threesixxqkshhnine7njtvvxfmjl8 +5seven6vqcd62sixone +three552 +hsslkhbd88zjhqvgtzpfour1 +oneone96fvjbmcnzrr +pspndcdtctwo6 +v3one9 +fivefournmrfrzghdh7twoxmpgkps772 +vdkqxqnsthreefive25 +kgjsevenczqrqf14pjchtfbnnninexhgn8 +lqkhzjzm3six1one3 +1three3l61seven +1flsfhznl +r8hnbpbtrzkstdg +hhrmnkktv7seven29fourpvjceight +2mbft +954five9fivegbmlz5 +dshbfdqdjjgtxffjmllgvxjfrstgldgdxjsfxbone9tgseven +fourseveneighttdgghnfive7pchxddgggcq +8zx5seven7pffldzjhdb8 +bpqslhkt33sixnlxckbbr2 +xqmxvjcplh4seven +jd9zxmz2two1kvsghkvkpz +9blk3 +6rjvmrjk46 +onetwo6ninehdrlnxgbc +6drvnkssqzv5jfnineseveneight +sevenmvxlzmtwox49one1 +8fxnnjr18fivefcf +five98sixkblsvns7mgttvhhz +85qkkg463lxdhzdtllqtv3 +fivethree5eightfivessrnhsmdrnvssxfgxmsix +xgmqjone7j +pkclcg54 +dvllcqqghh891pdlqnbtb6183 +2qbnqkgncqrvlfntwo +seven7qdfzfpfivepnbhrqx48 +682sixqtwotbgnsspzqcntlrhpzcq +2sffrxkgmsixfivetwokfvnlhz +sv9klzvnzsgjmoneseven +bzbppxbdpxs9 +68ninetwo99four5grdrrkpr +mtfcscprzkeightfzdbhdndqh1njdfourtdtflbfjrth +8nvdtbrfrvfivesixtwodzxfhgpzlk6cgkbr +3slmzvnine5fm +eightone16nine +kdzrjbh2txzz5hbone96one +17pgtwofl41 +eightoneqjvzv3 +fivetwocrhmvxqkvbeightfive1qzcxvds +2htzsvdhvqvdjv diff --git a/2023/src/day1.rs b/2023/src/day1.rs new file mode 100644 index 0000000..1692e56 --- /dev/null +++ b/2023/src/day1.rs @@ -0,0 +1,180 @@ +use std::collections::HashMap; + +const INPUT: &str = include_str!("../data/day1.txt"); + +pub fn day1a() -> String { + format!("{}", get_calibration(INPUT, calibration_line)) +} + +pub fn day1b() -> String { + format!("{}", get_calibration(INPUT, calibration_line_2)) +} + +pub(crate) fn get_calibration(data: &str, parser: F) -> u32 +where + F: Fn(&str) -> u32, +{ + data.lines().map(parser).fold(0, |acc, val| acc + val) +} + +pub(crate) fn calibration_line(data: &str) -> u32 { + let chars = data + .chars() + .filter(|c| c.is_digit(10)) + .collect::>(); + let number_as_str = format!("{}{}", chars[0], chars[chars.len() - 1]); + number_as_str.parse::().unwrap() +} + +pub(crate) fn calibration_line_2(data: &str) -> u32 { + let data = interpret_text(data); + calibration_line(&data) +} + +const NAMES: [(&str, &str); 20] = [ + ("zero", "0"), + ("one", "1"), + ("two", "2"), + ("three", "3"), + ("four", "4"), + ("five", "5"), + ("six", "6"), + ("seven", "7"), + ("eight", "8"), + ("nine", "9"), + ("0", "0"), + ("1", "1"), + ("2", "2"), + ("3", "3"), + ("4", "4"), + ("5", "5"), + ("6", "6"), + ("7", "7"), + ("8", "8"), + ("9", "9"), +]; + +fn interpret_text(data: &str) -> String { + let mut working = data.to_owned(); + let mut digits = Vec::new(); + + while let Some((idx, digit)) = find_digit(&working) { + let _ = working.drain(..(idx + 1)).collect::(); + digits.push(digit); + } + /* + while let Some((idx, digit)) = find_digit(working.drain(..next_idx).collect()) { + next_idx = idx; + digits.push(digit); + } + */ + + println!("interpretation {} -> {}", data, digits.join("")); + digits.join("") +} + +fn find_digit(data: &str) -> Option<(usize, String)> { + let mut lowest_idx = 999; + let mut first_value = None; + + for (name, value) in NAMES { + if let Some(idx) = data.find(name) { + if idx < lowest_idx { + lowest_idx = idx; + first_value = Some(value.to_owned()); + } + } + } + + first_value.map(|v| (lowest_idx, v)) +} + +/* +fn replace_first(data: String) -> (bool, String) { + let names_hash = HashMap::from(NAMES); + let mut lowest_idx = 999; + let mut first_name = None; + + for (name, _) in NAMES { + if let Some(idx) = data.find(name) { + if idx < lowest_idx { + lowest_idx = idx; + first_name = Some(name); + } + } + } + + if let Some(name) = first_name { + return (true, data.replace(name, names_hash[name])); + } + return (false, data); +} +*/ + +#[cfg(test)] +mod test { + use super::*; + + const TEST_DATA1: &str = "1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet"; + + const TEST_DATA2: &str = "two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen"; + + #[test] + fn test_1a() { + let test_cases = vec![ + ("1abc2", 12, "1abc2"), + ("pqr3stu8vwx", 38, "pqr3stu8vwx"), + ("a1b2c3d4e5f", 15, "a1b2c3d4e5f"), + ("treb7uchet", 77, "treb7uchet"), + ]; + for (input, expected, message) in test_cases { + assert_eq!(calibration_line(input), expected, "{}", message); + } + + assert_eq!(get_calibration(TEST_DATA1, calibration_line), 142); + } + + #[test] + fn test_1b() { + let test_cases = vec![ + ("two1nine", 29, "two1nine"), + ("eightwothree", 83, "eightwothree"), + ("abcone2threexyz", 13, "abcone2threexyz"), + ("xtwone3four", 24, "xtwone3four"), + ("4nineeightseven2", 42, "4nineeightseven2"), + ("zoneight234", 14, "zoneight234"), + ("7pqrstsixteen", 76, "7pqrstsixteen,"), + ]; + for (input, expected, message) in test_cases { + assert_eq!(calibration_line_2(input), expected, "{}", message); + } + + assert_eq!(get_calibration(TEST_DATA2, calibration_line_2), 281); + } + + #[test] + fn test_interpret_text() { + let test_cases = vec![ + ("two1nine", "219", "two1nine"), + ("eightwothree", "823", "eightwothree"), + ("abcone2threexyz", "123", "abcone2threexyz"), + ("xtwone3four", "2134", "xtwone3four"), + ("4nineeightseven2", "49872", "4nineeightseven2"), + ("zoneight234", "18234", "zoneight234"), + ("7pqrstsixteen", "76", "7pqrstsixteen,"), + ]; + + for (input, expected, message) in test_cases { + assert_eq!(interpret_text(input), expected, "{}", message); + } + } +} diff --git a/2023/src/main.rs b/2023/src/main.rs new file mode 100644 index 0000000..4f33f0b --- /dev/null +++ b/2023/src/main.rs @@ -0,0 +1,13 @@ +mod day1; + +fn main() { + let day = std::env::args().skip(1).next(); + + let result = match day.as_ref().map(|v| v.as_ref()) { + Some("1a") => day1::day1a(), + Some("1b") => day1::day1b(), + _ => panic!("unrecognized day"), + }; + + println!("[{}] {}", day.unwrap(), result); +} diff --git a/flake.lock b/flake.lock index 4fd5a02..c8f9c43 100644 --- a/flake.lock +++ b/flake.lock @@ -1,70 +1,23 @@ { "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1669764884, - "narHash": "sha256-1qWR/5+WtqxSedrFbUbM3zPMO7Ec2CGWaxtK4z4DdvY=", + "lastModified": 1700794826, + "narHash": "sha256-RyJTnTNKhO0yqRpDISk03I/4A67/dp96YRxc86YOPgU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0244e143dc943bcf661fdaf581f01eb0f5000fcf", + "rev": "5a09cb4b393d58f9ed0d9ca1555016a8543c2ac8", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-22.05", + "ref": "nixos-unstable", "type": "indirect" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1665296151, - "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "oxalica": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "narHash": "sha256-/ar+cbAKAxd2Ng9b7EhrIMz9CP353RbmLecvyOidyUM=", - "type": "tarball", - "url": "https://github.com/oxalica/rust-overlay/archive/master.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://github.com/oxalica/rust-overlay/archive/master.tar.gz" - } - }, "root": { "inputs": { - "nixpkgs": "nixpkgs", - "oxalica": "oxalica" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 665aece..cca187a 100644 --- a/flake.nix +++ b/flake.nix @@ -2,11 +2,10 @@ description = "Advent of Code"; inputs = { - nixpkgs.url = "nixpkgs/nixos-22.05"; - oxalica.url = "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"; + nixpkgs.url = "nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs, oxalica }: + outputs = { self, nixpkgs }: let version = builtins.string 0 8 self.lastModifiedDate; supportedSystems = [ "x86_64-linux" ]; @@ -14,18 +13,14 @@ { devShell."x86_64-linux" = let - rust_overlay = import oxalica; - pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ rust_overlay ]; }; - rust = pkgs.rust-bin.stable."1.65.0".default.override { - extensions = [ "rust-src" ]; - }; + pkgs = import nixpkgs { system = "x86_64-linux"; }; in pkgs.mkShell { name = "aoc-devshell"; buildInputs = [ - pkgs.pkg-config - pkgs.openssl - rust + # pkgs.pkg-config + # pkgs.openssl + pkgs.rustup ]; }; }; diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..3e044fb --- /dev/null +++ b/rust-toolchain @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.73.0" +targets = [ "wasm32-unknown-unknown" ]