From 0a5c1f77d01fc0bd166494787f24562e2fd3a9e9 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Wed, 11 Dec 2024 10:18:23 +0100 Subject: renamed day folders to two digit format --- 2023/day01/input | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++ 2023/day01/solve.py | 24 ++ 2023/day01/solve2.py | 65 ++++ 2023/day02/input | 100 +++++ 2023/day02/solve.py | 24 ++ 2023/day02/solve2.py | 23 ++ 2023/day03/input | 140 +++++++ 2023/day03/input_test | 10 + 2023/day03/solve.py | 46 +++ 2023/day03/solve2.py | 104 +++++ 2023/day1/input | 1000 ------------------------------------------------- 2023/day1/solve.py | 24 -- 2023/day1/solve2.py | 65 ---- 2023/day2/input | 100 ----- 2023/day2/solve.py | 24 -- 2023/day2/solve2.py | 23 -- 2023/day3/input | 140 ------- 2023/day3/input_test | 10 - 2023/day3/solve.py | 46 --- 2023/day3/solve2.py | 104 ----- 20 files changed, 1536 insertions(+), 1536 deletions(-) create mode 100644 2023/day01/input create mode 100644 2023/day01/solve.py create mode 100644 2023/day01/solve2.py create mode 100644 2023/day02/input create mode 100644 2023/day02/solve.py create mode 100644 2023/day02/solve2.py create mode 100644 2023/day03/input create mode 100644 2023/day03/input_test create mode 100644 2023/day03/solve.py create mode 100644 2023/day03/solve2.py delete mode 100644 2023/day1/input delete mode 100644 2023/day1/solve.py delete mode 100644 2023/day1/solve2.py delete mode 100644 2023/day2/input delete mode 100644 2023/day2/solve.py delete mode 100644 2023/day2/solve2.py delete mode 100644 2023/day3/input delete mode 100644 2023/day3/input_test delete mode 100644 2023/day3/solve.py delete mode 100644 2023/day3/solve2.py (limited to '2023') diff --git a/2023/day01/input b/2023/day01/input new file mode 100644 index 0000000..6edee3a --- /dev/null +++ b/2023/day01/input @@ -0,0 +1,1000 @@ +two65eightbkgqcsn91qxkfvg +neightwompstbkqv1fourfthdcfgtrkqzgrbfrczxbdn +43qsrrlxxq +898dbpjmdqjgtrvdvlxxdnvlfhncdzrt +jninedsrvftdlcg4hhztwofourskrjhcjvthree +five562 +bpnjmtmeightninesix2391 +rftqshh47n +ctpkqsdqz97zqptzjlfbtwo +sjtwonesix6cqbv4 +9zclhrrssvzpcfpqlshfsxs +ninemcctrb5glhmctwol7 +eight5fourtwotwo +18frdsvjxdpxf8dxsevenm +five55foureight +dbqeightwo4sxzsix +ftjjqbgphtmhthreesix1six +8sczkklgr5ncxkhkq +126dzbvg6two4oneightntd +fiveqcplndmmcsixksmmpdqgttwosixnine7eight +eightseven5threesevennine +nmxmcvrzbcppktgbznz2 +five83 +57rqxmvf12 +4nklcvfsix1jvsvxh8nine +tpjppv6seven4sixsevenvnhcxonefjztthdcv +dfkcrcfxkmxccpf7sixkzlgf +ninetwo6hfg +9sfiveffxqthreeqlvhbvrpbd +gtcmqsheightthree51eight +lhszhqvtn12three8xvfglffivekc +hntwone2cmgppck5oneonesevenone3three +8414onehlxjfqghrklv +cdtlrnine2onexfspkgltjrbone8 +tsjvxqljbfivefive11fourfour1st +dhhrftncnttrqz21fbdkkcdbndmdrp +jsfcqhzstnxxlchnxlztwonine5 +twothree2nhjzlhqdlgnplkjts7 +7zndkjxcp4xvqmqlgrhg +446sixqtk5fiveoneeight +3hdqtn2kjdkbzxx +onethree8ninelggjk38xt +2bdnkxoneeightonetskninefive +xcxfqtnpnmdmtrfivefour1seven +1cf +onefive5 +t5dnseventhreehbvkqzhbbttvd +49kdxj +s743dflzcsfninefour8 +eighteightfive7 +2zjsxntjfbkc15vtfkltb7 +knkmdgggk95two2 +dvjdztx6kfzzsscfcj6zz +xvcnqppc4five7threethreeckhtmfeight +4eightthree9onexmrhrfzjjjmfm94 +threebr7 +four188nine856 +szseven9269 +rppvmpprsgqbvbskg8fivedgpv5 +992one +fxthfh9twothree +jldmzlktzbhlsrndvn398five +vdzhddpsix6sixsixvbqmf8mrgnqxsxvxvdcdzmkc +7tv9 +37seventwofour +seven1six723 +nxjlgr64tjlqzphzjdvgb1nd +zmxldpjdsixvzcmrxxzl6 +91cgn9eightzxdzfmj +skhtxclf2ninemqct +foursixn8two7srvbbdldpbtwo +two5gpnnhtseven +onepqmzphpgfive2three +5vrgsfbj +5xmqhfbdt965 +263nzqjrklqkgtcgjcnprgtfj +78qrpdzmczxj7fourone2 +6threed +eight2twogr +96five +2ndkfivetwo6 +41fourckqxpdxdctnqmljkrl +68fzpjjvfhjv4fourhsvqtwo +ffqnvbxdzxhsxg9sevenkhpmnflbgfqsvfzfmxnlfcq +eight1six38one8g +5xhdtqshnc9foureightwog +two9llmcgxhjdghbv +9twoeightsix +f4qmsfgvzxfvxgq33twocmfnd +vqq8two8nhsqpgqnzrsixsix +dbxfbl98nllgpsix7 +svzgxfspxjfbcvonefour4 +eightonefour3nine8 +tqhgbkzmhseven656tczxkfkztwo +pckdctnzvxdgz4 +5pg +7two7vqtqxmddlbhppmpx8kldcgcfeight +gdbmfmppzl96452 +rpnmhfzclkmftsjkpone4sixmjhbjprx +16ljkbvbbc77sixvjlcpdqkvkcrfqslfzvtrqf +4threetwonedrd +seven5mqgztxfqdfdssbc +6eightsixpb +7jqktjqrthoneeightthreeqpssplvh669 +fivekjfktwo21jgtjdxeightseven +cjfvqzvtsstsvqsdgzlcrqnmmkgtvlclhfddeight6 +8247819snr +684 +threedqsvxzfmgrbrtjmjtzjeight57 +1three1233tvbpqrlrpz +bxlljzgmc4twothreenldkshgt +eight9dmzftbzmsgmxvhx7khsgvgmbgg +threehbvlqone9sevenxbccbppjxj +jthreesixqlxlvtwo8 +cg5nineonejtmpthkqncdmcrjztml +six69sixone5fourvhnzkxqrkm2 +mkpqfbjrninemvngbxl1nine5seven +qgxhthreetphvh4fh +four84 +8cdhf9fivexqsxljf +eighthmfq788eight +sevenktvsvvxj8fourgdbnpnthreethreenine1 +zlcmzfsxdvthree6 +mscdeight3 +lhzcxzthree8seven87 +rnrldrcponeqfdlxgz1lpxtf23sixkdqz +6fiveeightsixthreefour +onetwo1nine5gsvbzlsfrp4 +fivefivesix82qhdhnxbgmbttgdqq92 +jk886lfour +kcqmt6qk7gcdzzzzdljdmh3nineshcfnbnnd +sevenfour2krdvsfour +kbvlbhfbjqnr9three +two17 +dlvndnhdbjgtp57 +pqvxgonesix8k72pfmsjl +eight7xq3 +xgzxgtfqvsvvtfr23fzkvphdjmm +8hbkggrpxq8two3fivefour8six +tcxntnppqtbflnzfour6zzgrpvxjtf +2sevenninefive5 +sdvxrpt5lhzmkknseven2one9 +7pcpmgghrbt1zpllhshcsnine +cf8 +mfxnmj2ninesix58eight58 +8hfnnclmmsg64scdrtdkfivetwo +9four1sixj1three +7nrcxngrxxsixmccsb4rhztxmklmccpttwo +jgtdvpseven7two59 +369seven +onegdlthd9one8sixseventhree +6eight9seven +94five +6one282three9one +7rgxznfbf +zrtoneight9sfnsixninesevenzvqdxqjrcdm +five6sixkxksxone3six +qjqrjkjvplkxqvthree58ktgq +7kkc +hr54pmdtnpvzrlskpqrrqhbrnzz +99sixfgnfour389one +ltteightwothreefourfivenine7 +kzpzschjsptdpd6fiveninemxfxlkbmfl +eight7dqpvvplkjxgrxxtvt +41nine +61 +5qfneight7bhhnine8eightoneightfrx +34cjbcqzeighttwoqfdtqtqbl1 +twofivehbxftnsixhtffgqksdseven6 +84mnkvppxk18 +62four6rsph +8fourctcnnzfz +5jngcrllpnonefive +grmspdlkv42tdzctls +67sixeight1 +ninetwo52 +9jdvzhzflgxmsixzklv4cldfivetdmhrlm +eight7twoghldrbzhleightjs +ninenp8 +jxqjeight48qljhkkbfctonethreejfqlr +z9lxzgzkbmr7jtgpczmvblfour1 +545two +56tkxjhndzmtwofour +1ninesixpxxxlfnfn +6threesix9twojrmtl4 +6rjzjlxh5tdfkbjzvm +g8one7ccsix +4jxhxrgrhxv6threegkdsgvzxpzzrjclzrn5 +qhdjbsh5 +8mmngf4lpngqnbtxz +zstqrl5sevengcndbztdcr +mmdsseveneightfdbthreezbqkdbb3 +kkntgp94937 +2zrzntn8three +klklfnxcnmczrjlprktwo55 +7ninecqjtkjsdkqgqvcxtcone6 +bgjjheight5txcsjbvv1 +rqbk4 +soneight2qxbfdkdn51ttfourfiveninesix +czxhmh73llnlspseven8hfqzdpdqmg +26zmphsljkkddzbkninesixnine7 +45six +9f +6five6nine2sevenzzzmvzlh +hfnfour8blpsixvhdz26twotwoneft +87twofive +6one92six34vfive +nine82nine5dbmjmsixseven2 +6rmgq8eightqxrj3tkljktsjxz +onefour49sevenfour5 +sevenftckbsfivegfbgmpcvvvtqdhmbfive8 +hqrdprfhxpfjnlqvx2fivethree9onevxbqtpg6 +clz76eight +seven6fourjvxzrfivethree7cgtvmsfzb +4sixseven7jktrblrk7five +tqlgpnp682qnhpspbfm +mtfive4 +6ninexkds1slbdnlfp66nine +9sevencdqf +jcqccfzmgffrxjcvhpzonerlzkpvk71four38 +fourtwofourfivetjzpqmzvmmcseven3 +zqoneight9 +4twotwo +eightgfqzzcs8eightkkklhsvkmsseven +twosix4 +eightfkthjb83 +8gmqlpdbftwo15sevenjllkpnp +378onefourlqcq +rxlnmcphmzckgz9bpzonezcjcgvdteight +sevenfive2rmzbpmfvplxdvvldnghmfive +tvbctwo1twofoursevenkjbjd +veightbkkp9vntmeightjdrc +ltdmmnlsjzzxqtvnghxjnvg48bqvvvcj +seven4frssnmkjhf +nine975 +zcpdghhlhrvcmxftoneeight4 +rgkxgfkx6cqdxjhdqdf2eight2vzkbbpklqnine +one6six5 +six5seveneight +23krkcf +sdpthreetwo3 +eight28 +3twomdpsvbpvhthreegfrdfqtnttk +9sixsixcqbdd94bzxmjn +6fbbbrvzkzbhhlgthree +hgrnflhgqhd6628three +58tfxks +rfcmcfive51nine +3eight9 +6threecktkhlvcdkmcxdflsdrcfmkpxrmq +fourssvlkcsninesix38fourkfrgbdxlhx +mbhqsceightnine5bzxfnrzdgcvsg +gfjlsvmkfourhf9qfpxmlqkninecrbnjrfpninejdntmjglk +fiveonesix58onefourdnl +hkd33lgcjrpf6four +ftsbbgmv3fourrmctcsxrfv +rkmgfour58841 +gmgskgrfhc54cvpgkkhdhfseventhreefour +three9onegjdmsfthreelrpqfj1hdmbd5 +mkjbxcc9375 +onejxpczj2twofive5one7 +vhclzbp77 +8onesevenseven1 +3seventhfivefiveseven +bpnrkxlnxrq4dzjljgjg2five4three +fivekpxonegm76jqtjrlrns +pmmqkgdmljhdvsixsix6gdrrx +6rzjmrhlr +sixqnblcchkfnstwo9two4xdjns +twolmffnfmdfptjcdtwogqzhtbvph18six +5threefivefive2czfcvqrjcmlcctgninefour +9cvntxx +4sevengzlzjnntxz9ghcpcgvbm9three +2qcck3one +sixqxqnjxk6ls1rdtxkb31 +8onefiveeightljp2 +six7one85ptxktrlbtfdtz +ltgnfzcjblvrdclkonesqgbgplqm3threeeighttwo +1xmnr +pcxkjdtcmnineeight1rl8four5eightwoqvc +twovlhtdxctsnsixfourvsixsqfhbjzklsix2 +6hcdhsgzv +1six8qjdsfbnlzj93gpj +twoxfktts2xmjvcxkjjf +gkgqmdxcfkb6fjjzfsqbhnzxjzsvzkfv +6oneonefourxrnpf19 +qqgsckgrrh5svt2vsd6 +sixtns37 +jqgfcbrd7eightsixrgkqtkf +4bkfpntttsjonemhtcgsnzvjxcftzssdlntlv7 +9jvjqzgrzxslffdfhmcfournhqfckgmfnone +dgeightwothree2zhzfb2 +tldpeight77mh88two +49fiveeightfiveseven4 +three3rpbrvnp2rgnppsctpcqqfd +1one2sixfleightwokhz +7cnnnp6lzcjxfsqbbfqgvnqhklcktrvrlmfszmqchfnine +one9sdqnzhhnine5pkqthqsskrfourgkxbqpzkrxpkrvnk +gbhvg145twohnqfqnj2mxg9 +2sevenoneqfzbfqpcfour +pgcxrr3qhvngreight3four7 +vvbfrnqvgmq3eight3sevenllllfn +twonineqtklzqnd7fourjpqthree +82sixtwonez +nfmjv8pgqtqnkpmb83 +seventwontjbdcs8mthreeqdgfg1 +2fiveqeight +3ninexqt6fourfourone +9ninesevenzmhskrfour2qpqzhqpbgrfiveeight +twofxmpt7fvxkqbht +xmtgrngscqninesix5twotwo7 +onetwo8nvhckltwo +686one1seven +986l +4ninepxhzxmhgsixjncqfhqlnb +5tkvsnpp +njfqd5eighthgzsixnhxgt +seven3seven8seven +zceightsixninetwo9vxmfscp +threemgb77nineg1vzlbvhgrms +5onelfpdchkrqpshsixtwofiveseven +6zmjpkzxttksevenpkbdvksphjseven +smeightwo993 +one987cckfncdctz15sevenkdtrzkkmdz +8rhbpeightseventhree9 +nrnxccfzhrrxhsjhlthreethreenk1nine73 +nineone5threekxv2 +fivertwotwonnrlhqzfpbntdjhv5k +ppqtrhfkdbpkflpnlx85nddjxdctf4fx +lmtwone472 +3vcpbonejmtssvkn3one +8twoninembzfkjdtvdnd1three +eightsixzrrv35hmcpmgjkchfourrg +h87lhbgmzg48twoonenine +six1289src +5fiveqrmscnnqn21 +ninefourfiveninexlcpxt1 +onesix181onesixjds7 +4zvqzgvcd9dzhjzkcgflnhhfive +6threefive7dlvgpzh +3xtvthree +one3cjckmone1six +sixsdtgjtxhsh4qmkqgsp +bznsevenfive6seven6eight7 +7ninetwo4scmttkmkmhjgz1 +32fiveffxpvvfive +8twotwosglcjkxtfour +8ninetwo6fivetwo +ninevjfqnbqshgcnznb2two4 +1btbsqfgxz7 +37skthonehgnine +qprsldzcbzcskqpgpnvjt4fivegpqllvq52 +qnqpzpkmfj5ninejsix6bpcn2 +28jmvbtljsldltwo68fssrjvqtwonev +fourthreefivepxqrrjm7threezjsdhfs +7kmhsdlrsqlonegbr7 +onesixfourbdcgeight53lzpgjlsz +qgpgg377 +five17 +zpmslnjkqc3 +fourvmqhvhdgseven7jtpttjlzvsbfkdrj +bdgcfcsevenfive8527 +1ninesevennine +4sixfour4nh7sixnlkdk +shjz737 +7onecrhjhbqqnn2sixqqgseven +6six1kxpczbxoneone +512vnxncqgtsevenfivesnc +sevenrrdrzlht5 +6ltsix +87sixfourgjh +ngtzsrpxsfpmjzk2 +onefour462ql5mcfqrglrp +l88oneninetbh5nine2 +scgzzmeightqrltnkbjxrglbvsrpd2 +7krheightjlzzmthdrqsnkdqqlkone2 +three4fivexn2nine +sixseven8one6 +seven46five8 +bmbfd8 +one99xgk2 +fivetxfjpmnhdl7 +gktgcbronefiver2d +444six6 +dpdbxrtnnlsfkh694xnqhszfbvcc2 +53mznqnine4dpkkx82 +6sixldcgszrhhvrbhdnc +djfpppftbx6three9ncfour5two +eightljcvn565fivethreegsjbfsjsc +grdtdczfm5krxslvfk +1threekpnhkjbgch2 +four37 +ctlxgcgzj57gmninethree75three +lffrgk4 +one256jxbthjxhtj989kfqnrdhhxz +three3ddsxpt1lgkzlpxfiveninebsnbntpnnine +qxskrjjvtp1chgksksxksg79 +8zjvmfkpnrc32twotqdc6vshzv +8hgdrds54zk +twokr6vkbflkfrcjxvmninenineeight +grjxdtngmrthreerqjvmxbrdvlmqninegslrzfgmcpdhmg8 +5tkdszfcjdm +7jbzvrdprgdx7npn +ctwoneqcmffptjzpone3brdtb4bjnzqx +eight4tjfvrvlcfgdtk61fouroneightjvf +eightsix9four7 +827 +8pgcksninemrt +bggbhgh8 +fiveqsqvlsxc9jnhfdtqvsq71zvlh2 +3z1mrzxfdkqsixseven +kbrtclpktwo6btgpxnbrz8 +5ninefour6three +8ninefxfivekrkklfvnr6 +ftkndksixznvhxrdmj414seven +fourdjjxhb3 +four82 +277leightsixseven91 +4czktzmzctsdqgpqthreekjfm4 +78onezmcxjbrheightfourtltlrnjpg +zvclmdhrrbmslgfmrgtvzpnvqmth1one281 +dnkf3seventwo +sdtpcdc5 +rtn6vfmtvg +gkeightworqtjvmc3fqpzqsevenfivecxff +four49gxrkmfdl5three +9nine3326bcxnclqgsgbng +mjrvfrz7frq2sixfour +twosix3 +j7 +four73zfrdrns +st14pjnfgqpj +dlceightwo53dcjzxft9 +333mzmtlrhkjgsixcjzdrshhpv +vp6stsvtntboneseventwokmdvgthnine +92v2thc +seveneightfivetwofour6 +three76jfx3ninekndxqschpfive +fivefxgbhfour58n +nineninezgn6kbblgf +rjvrx4four71one51 +4mvmdqjfxhzpddseven7nine76 +86mbxjvs +3twosevenfiveh8fiveseven +54bczbfjq9cseven5 +nvghzbcjxn57nineldlklgb5fdkqvbzftl +97mtvstpkrzkrg46four +tp8 +four8sixphlcct5 +2pkccvfmp +ninevmvlmvqqnone69foureight9 +four2xlqrmlp48vdzsevenhtrcjbpc +ffvhhtgz78threeone +bfjnjxr342555 +4czvdggxlbzcthreerjfshqhmj7 +6three24khccsqcnddq +659 +five3lxchdtfvlnjn9mcs9jlsvzbcgvk +mfnonefivetwon2mrbsc +hvxv9three5 +75ninektwoseventhreefour +zvjrcxchzrz7seven +jhmbsknfm5498qtwo +scjnfvnld72gvtzd +8fivesixtwo +tdjkrtrdj7twoneg +8one3five +2nncbsevenseven +fourtfqfnsixfourtwo9threerblgths +twoninebgxnphjsixseven4 +threesevenxjgbpl321 +fourtwopjzfourqvnknmmdlsrhnkonefour1 +six9ninevkxnpmnpjrmnptwo +eightseven4fivethree8 +nine6nineonezdbrz621 +4fivezhvzlvrblm3mgzhf56 +dfkdbtreightfhrp1 +oneeightonecpnkkhpcpqt73 +nine9fdgbzxhvbslzlhkpone78five +two74 +5three36rl7vnk6one +onetj152twoqtjgvsnjpd +6ninefive +fourszvmjknhhvmznine73eightklhbbnrljk4 +89eightjcdftnine +gn7oneeightzcshvfttpnvxrxjdc +four78five44 +tnqmjzd2fivehqpkrkdrkqr +eight6eightfhbqqsqqs1twolhbfsjxfxj +4two4xhppfx +gnfqgghz4xnlcxqpccktwofivextpskbcnn7six +seven133bpthreeone5x +3five55four +6pgmbbbnmrrpdqzjkbsrpfhstwo +556vfzmcbxsqg8 +59fiveflckfmthdd3nine +2nine5six2twosevenqrdp +qsghpdqfivethreefive8 +ninesevennine1 +onevkqcgdc6 +bcdspxmhzsqfhhlghmqh5794blxm +8eight2twomd9gvtd7 +gfjxcczktc8 +ccpgbl3zqtmqjztwox +jvkvvklb5nine2dfsmkljl4hpjbhlpdmt +3rxzrnkdrnltzd +fivetwoone6 +zcsf5rnxgckhktworqsqngvk8xdgtfcdseven9 +rsbfcsix3jbqnqeightsixonelrhfhlldhhfg +njpnzndmdfzkpdseven5rvcsxheightthree +ninethree6zplfz1seven +7dknfz +ninebkhfqdsrone2two5six4 +1x +mhrzpkcmf5three +9vzrqrmtzqnkdhrhv +g3 +sixthreefourtwonln9fourvqgbbht +vfvzttx86db +cpcrxvp5eightfourseven5fivetqnine +7fsfmgbntxrmjmpmmkcnbx +sevenrkmm6threeseven +fivefivebgdssdxqfnthreethreelvln5eight +vxrxtzmtmtssjsevenfourmnhtzdthree4fivesrpcrb +t8fxpzbnfivesix6fhrcklhvfive +6threetzjvzkbdp +gflz6nine5 +ldnn7qjz1lcgsmvjpbtplztmvseven3 +threefourtwoeightdfpbjbggx3m +4nineonenine6kkzsmfdrl +lmmpsdmnnsrgkbzcdfive5 +4onethreejcrgddkxthree +9twonexr +pvjdlxv1xlgkdsixsixone1four +fourtwofivenine2 +xl8 +tfmfive7 +9q8svkhxgvbmhseven +fournmtqnnphzckqsnpqddlvgff1ninetfhdknbnl +6fivetwo59gxbzxrkdvhfive3 +ndbrshkmc9 +4fourseven +lkdcxdkkxthq5 +ftwo2pgpljh11fpbgl2 +hhjrfcchcjlhninexmv6 +9bpzdrrfqcs7eightwob +8eightfive +57nnbqt5eightzvfblxstz9scfnnv +92three7xkkdskhvseven +ghlbrzxhlkh63three +5nine7fourtwo78 +3dvxdphhxgrbfrlq4qxzslfng8rrfjnpjdnxc +brq68eightoneightvrx +four7twooneeighttwo +onenine2nineninesixfive +slltwone8kngkhvgkkphrmgprnm9 +twonhsxggcslm3zqmsixfive +pzgpspbfivetwosix9btjbdfbdeightj +fivezpdk34ninephlzvddrmzvkztwo +sevenfour223qvxrdrvqgkqpctbrzeightqtxjnhgz +7373sevenrrsfzsfour +rttwovggcqtzx2993 +twonineonegpcpdqrpd284 +2fourfrzkbkhninegseven83one +1pjqvdntbseventhree +eight19tszhr +hngn5fqfcfxrnfs +6xsxcgkdstncdl19c1two +cvrdkrqrmssevenfivecjblqxjbzqtvkqhmcm18 +zqtblgtqttwo9gmkcfkdcgbq83 +bdrmrsrdfponeeight3fvvsrfbshbzbqztmhbbzpkxxnb9eight +4trjldtsjdc8vkgvseven +37fourfive9three7nine +fourseveneighteight7fiveonexxmmjzlbhk +fivetwothree8seveneighttwo5nine +mqmeightwo3 +8cjkdcdk +6cjnjht51knzzcsqkvtwo +5dshlzzxxggninesix1two +9seven1eightonef7 +two75sixfivesixhthreethree +1fntfzqrjcxlfprglcsix7 +4lgcgkseven +r15two +eightdsxsnqgfnbntvnqtsfpr1 +sddbms6nine6 +7tpdrfpbd +flmztqone7sixzdqlxhfiveoneone +jzpvdcvnzmmgzhxlcsevennine2 +nineseven3cqktfscgtf +rdhrxhfn8hbhctkkxz3 +7cjzxmlvq48kvmxgmcd +twoeightlqpfv5fourdfv77 +8sixfivegnsevenlgdkfcfznine +fk8hcndpfflmsbjlseven +1onesscdrlztwoonezfm +n8xdcmfxvvgm1b +psix3 +gmpnine5ninekfmmhbrnq +713six +gqplptccrthreethree3jdgbtx +1onergncpbv +5fivetwo7two6nine +4sixqrrtqjnv7 +onetwo7364fqrjghsbzp +five7shstn +5sixkcspphnsxndzfdghh +jhxpxxpfz4sfkpgeight9ninedclxgv3 +fourqfzqsgpt4ljtrrxn2 +8seveneight6fhnf9onethree +bjgdq8two8m6bnnbdtqvlf +eightgjrvdjhz6 +rdkvkqhfourdpn7tkjbflm7 +1ptthreeeightonetwogbh95 +92four96 +2sevenpkfgj75 +lpfnmmp2eightmbrzxdskx7ninetwo +gjmxfive7qqrbsr +qxprvlrhxlj1threethreevrvvc2eighttwo +vdqmnccqsplkpmspqcggvllsxvh1 +fvdhvmgzseven2fnrrslbdtwo6 +fivefive9smbxkkp192 +vbsdstvbknldcgkzkgqjln7 +mklnltnfsixphfgfzseven8fivenine +jbshrqn2three844 +6nspp1one7three5 +six3four571 +nqjssphmsbhbfhp822one +9kffmtffiveeight3 +sbfbphdgjh4sixbfcrzmnlhxcsksctb5tdtm +7bfzk7mvrglxjfour2tzrkz4 +onethree36 +zdtcr45four2tpgqsix +sevenmqgjhcjpnine63zllrtnm1 +jnccdbplkfq6oneightd +one8flhbdbl93 +rrmd34 +six1lkthggkbtwo5onesixthree +eightl294eightlb +eightzngvqdmfgvfvhlrxnfourcfggfgp9 +dkmzgc73l +839fourone5 +xfklsdj6three22 +soneight6cvgndhbtttlbpqktwo +5nine1four471pnnvsix +zqrfmnpgzkqrshrpktfbndvfmrcjhfqlhcbn9rrffzngrhnthreedbgcm +xcmt2fournine +seventfgnkd87sixthree +77fktkx +3mdzzsvdmltl7jeightfivenine +seven988five +9975 +eight4sbc5eight9 +mxj53bsh8fourzv4 +817 +99ninevnonecfcbsjgnrzrdffll +twofftvkshm4 +one221jjbtlgdtt +68sevenfive2lhrblxpkdq8nine3 +39cjrgljlvxdfivenhptwoccjbhtnmqreighteight +sixfoursix74fzdtnx92 +rhpktnqsvqxn51 +35nine1 +43gqzppsnktxm2 +5five566dtbppfp +nine7one23sixsix +93fourbqmsspdhr +cm5qcfxfcsg3qcvstwozhsnspg +227two +qfrtvpnh8 +one4jzmmmjjk +4vxvngmtjxldcn2 +bjgb2kvrlshdvfj1hnpfbtxkp +7eightpzmxcmcnsmtkxjt +hzhjbddqj961zkxgmhxdthreetwo3 +7fivetwo5dvpplrmxqrzxtwofive +717mfszgrbt +chqhsqt7hcmbjqstfive +threesevenkknvhhtt7399k +7n +6twohzlngv +eightthreekkgt9mqzvkql9txh4 +8fcsndmltseven +twodjscb5sxfourtwod +5ssbz +onedvpnnfvqxvfour1jggdsxfdgrqfrgvssix +sevenk94mthklgmsxhxdjxslvfive +bjqshcpk26 +nine7sixzx7 +9threexsfqxqhvvbsjzrbmxcfssix +geightwonineqp7twoeight79 +8b8dllrmvgnmhshvkhm +7grpghbfourlsixthree7 +1xzrhgxsh7threetrqqvsl1hcmmk +fivetwoppnseven9sltkmcsntzldvqzfour +6flgcsj +nine44onedninesix7 +hrlfdsmjqtbpfpxljhjrrxrrdnrlzf34eight +sevenrzgsvq6 +39sixjshdjrfmstwo2tzmzhgggdqgflp +tcrvlffrmqrcx6bqbvhlcbgtwo351 +9281qzt35jmtpjgqq +qpdtvpmfbqrmthreetvlsr2fzbzkthreerhqvqbcnj +two3fgrnggpcl +7onexrnvssfjczlmkzgprnone2khmhntg +6lzggxthreefour26tnxfcqbl37 +8rgnffphzgponejfive +bmpsevennhrkphhbfz8nine +5mkbbjdcqninenine9 +zrfvhcreightone9five +19chrfkm6gqlfcfhmslmcmr +dzrt197twonine +vmrlbm5five +pthree3six417frljvddzjtgdvmmh +fournine7lmzdrxvjsixlmfsgtwonesn +ngt8fdcsgmbbvrone3 +3hfhppzdfp +sevenqvrlkpgxnqfivexnzpxcnine99 +38oneightg +4fivezjzsstlfxp1pdjmmnvjvtthree +xfngrdrfseven5rcsqtflhsqz +three3jtndtxpx +eightfour8xxtkjsjlrsmg6 +1qnjttkhzltvj2xtlts6lqlxrf +eight817two52sixgmhsrnlzm +fourgxbk81 +eight6eight +4pllfiveeightsixonekhxvhvx1 +41twothree +9pcdldnine +vkkncnrblg2x36 +sevenzrqsix3 +ccpnk5threeeight1 +rj69 +ninedzgnsvrjbg4eight +nine3onesevenxvpmmt5eight +drcbrg9eighttvdqgrchlqnineseven +five6two3bgzgtvxmj8 +sixfive9 +7txddsmg2hzhz1fourkkthree1 +3pvgxxxmpt5eighttwocnvnine +cdnbkl3 +twosix9sixninevftwo1 +392 +427twozqp79sixtwo +2jpkrm16 +threelbspfkeighthxmmcpprmeightthree3 +bvtfzpr36nine +qdzfdzbvnk47twofive4two5 +ninethreedfzrphlvkpbvtvmzjxgmrh6five +cjnq7gnpnpt +six8nine2 +chsdgnlrzqnddfjthreebhfdvlgfpfshkeightseven6 +nmlqvslhk6fourninexpzlf9pfnbrnhphxzxh +eight9nfgtsjxnteight8pfpfctjxxbffxsmjtwonegcd +nine8m1 +9sixseven +218 +6brzzmkxsm +ftxrrhzz1five98kninepc +3kkmbvvvtwoksspmqksevenoneplone +eight3sevenfour7two8md4 +jvtk22472 +threetmpkcsjsixfour6twoseven4 +kclmjgdplc23ninekmqbrkxrkdhsnnhmthreecfive +xkzbzkszml641one54phdfghtbdd +3442four8vr7 +6lthree +lfrlxpczfiveseven2 +fhjjlb1fiveninempnvlzbkhsvqf6 +fiveone66onesix6dtwo +91bgqfz1four8 +7two8sevencvfjhqmdtfone +889two3db36 +sevenhlljx5qoneeightfivemvsmbzdbznine +one45sixft6eight6rbf +gdsevenknlfourkmzlpvv3flsfvnmfseveneight +3qbs622fivemzqpxdfkssix +275fr2eightoneone +lktbgbhngfbrzdponerqstslfourhjxgmv1qcj +two9fivelsxpd2six +9eightnine +qmteightwosixseventznkgmnhjvdfxvqv8 +ninenine9jdgndgnfour3pgb4gdpjnt +three3sevenzcbllclmseven1threeeight +xzbkxnttninexsj2 +ngrgdonefive94fivehgnt7 +3nineqnvhsninetfeight22eightwoqf +phrzskrhbd9five8nine +dqqnfive1 +hsjrhjvmlqxltxxgqx6qbfsnrhgbkl +four5hrpnq +vfsqhhgb6eightgtjlvnxnqsrjn3pg +71fiveknrgx7 +dpeightdbvpnfour1 +two59blldsls85 +three22nfvmtd77mbjnvxqbdxkxvp +five56five22 +jtqeighttnkzkbbtwoninepzxphtlbzsv8 +1zhktrqsklfivegxdhrqt +three422 +8sqlrqn9 +zh8 +1fourone8 +94kkqb9four9 +6sixkbvxf +rbvxqgztwopcbhhgzthl6xsix1qjrvfive +two29one594brhbpnine +7fivebczzcfeightfour +bxqrdcx7sixthree +xjqchs31twoeightthreesevennine +83five8qvnrcllfhddhltsevenone +gsjjxtvtck7six +cxsbtkzcgjbgninehhmzzfnine3bpzg7 +six7threedbhtvcvjtmeightz +pdfmjbqgvkr5t +cqbkrkfivexkmvgqfbfsg5zmfhbqkdcq1 +6ptrseven65tvbjkqlhjhjq26oneighthsp +39eighttwoninetwomnszqrmtvj +hfpcgzrp8pmmvonevtnfpfltmgxqzntwo +seven6cd8eightr +1vbpfiveseven5gsqdpchrjzfour +7zlxvvjmlnonesix67two2sfggmgbmm +rmgvfvdhhgztrrn966six9oneone +6nkvznctwoone +eightthreeg9nine7six +shthreethree1 +tm1eight8rone575 +nv6 +tpkgndlhdzlfour1fouronethreenhmgtjzn3 +9onetwol2qmltninehtrmfxcsbfghk +2vbqxkgp5two89one +428ninefcskeight +g3fournine55eight +hmnvcgtqsixfivebone6 +mpcp55xdfive33mdbsc +bfpfrrlqsixfq9cnzvffncbn +hmpvxz3fiveklnnjcvgxtplhhzdrn8seven +gqr6fiveltkqqfvkhconeseven4rlqnvmmkgcx +two2eightwokcr +eight1zmqpcjbbxkkcnk8 +pq6qhfnm +sevenseventwo5three7 +7eight1mkpmsvpmqfjnvqzgbjkmpc2 +gtwoflpblvv6xzpblmfcbx +32five +four3two843nlxxhktmcdoneightjh +89gjs7eightnineonethree4 +4rfcbkgrcfb6three7jblgcrrxp5 +mhs47tqvkt31twofive +pspptsbp55 +fourfour5twogdvjvskqx8foursix +eightxfvnrpcvjtfkvlng91eightcdgzhxzcm +nine5psngtrxms5vnrbjjrpgt +5xnlqscssbfiveeighteight14 +svzlbtdkhs5eightfourgzhsix944 +fourbphkpbkcfss5l +4four6 +onetwo99 +nzhlddbkgcbxvpfour1twofiveseventhree3 +2one2txrzz8fivethree +seven86 +two3tznttbfkzzbthreexqhxqmbj +dskppdthree2 +seven4lfive +hnftvrk8fhhzrqzxxqzbhvjhflv2nine +eightsix2zbsgtdvrone +rmssljck3sixfivehvsvtwo9ctrbfvhpxfrr +3nphszlp7ktrtzflbvxnfive +cfrrckdlfmjkmvjbtxnsdq613hxlsix6 +spljfjrlrsix2fsl +threeonezdbmxps9 +two2lnbvmmpnqq8ssonethree +vvpjpvm6two7 +424 +threek811nine1five2 +82mfsgmh +ninerrjtnkm4nine +sevenonenine7 +nine16698llgxbbglggone +knhnxtj6ntkxnine2eight7 +286nx +twocbxfonenineonerxvdjzjzcp2 +2one5 +ninethree25sevenfour69 +chthreeone9eightoneshlgndnrjoneightcs +2onenvfszxbphone +9threefour +eightonenine28one +3bshksixrlncdqtk3foureighthjcmmktsvx +prlsj7seven +gqxoneightzmcsqsbvhbthreefive16 +3kbqbzm2sixnine52onekrtoneighttq +hqnfive2one +jfive17onemzd +6one2eighttnjzjk +vtmcxnttlxltcmseven2svp2pnzkbgzzzj2one +54mhqbcpzgsd2ld +3fvbnineeight +fivejrxqnqp11cxeighttwojqbqnhmeight +twoonetwo49sixxjbkdoneseven +7qnqpfb9xrhtxkfz9three +one8four1 +2r3lrgjltxxlrhrvfltwoonevq +jkptfcvdtwo347mjrqd +eight9cxstff +7nqqbkcsftknhqffjvr2sevenpkjvtc +seven5sevenrsthreefiveone +8mmvdqhone584eighteightfive +7sevenjjgvr4 +465nineninesqnslzrfpl +ljqnr737gvfmpjztrsbns8two +hkmdgbbrzpjczpqkhzkdmndlftxgtwoeight26 +nhskzhxfk26lpklkkkdnxeight +sixrqcjqseven7sbqlnpqvshxninebxmkxfrznine +xlrrfnt7jjhfqzr +one9six3 +sevensevenpsbgtgqpmbsbbpldvbz2qsstxlcgkd +5qpmvbnpfiveoneeightsevenone78 +four69seven +2nv +1twovfmvk33gcrsfgdbms +fivetwoone93 +g4sixjbcqttbhnp6fourfplmzdtnltnjqdsthree +f3 +one3ninefiveone3hlsthrp7 +lmdgzgkrq747nine +fourtwo7 +7353bdninesixxtc +njnsprmjxcjn42sixp1 +92onefour +5eighthkdf +263fiveeight +four96one52fivendcnqcl +rcntpkdtjlcxkdg8 +nt7g55ninetfzrjmhrv33 +two19 +ninefive5threetwo73pxjfive +onethree42 +9dctnplfgkeight9 +xpjtknfive6five +q1ninefour7 +twohfdckgcddpmjbpmgbxnineeightxcxkhssjt1 +8hgcs3onemnrcfbgsh9fdc +7zmgns94ninenmm +3four3 +hrrt3nine292fourfour +ljsbmrfmnpgg799twosixfoursix +sixjj6 +gqmvmmjsjrgn7fiveninetwovnjbs +m2 +525onefive +ninesixlm7fiveeight +fourfour6eight5gpkpjdxqvrsp +two5sixkrmxnszf1eight6seven +1bbmmf +26two +9eighteightfivesix7 +mcjcdnhlxv92qfbfbdpxfnxgbqsnxkonethreeseven7 +9qlvlrfivefzdxpmttsllhntpxpfthree +djdjgxdpnd82five +fiveonenine19four4two +five69two7sfj +twoonelvmdbdq2two +qxeight6trprdmgqzj4 +eightfourdvmbvnjthreetwormzfr4qgdctg +fournngpdffcxt1six +seveneight6zeight9 +fkkmfbd7nineseven +twobtkvbzgplfpjfiveseven5 +9jsjkjhgtghbqltldlcpqtvgpmhsixsix1four2 +kxcgkvkmnblfive438 +six6lbbqlttnvfiverxceightwobx +8sevenseven6three9ptfggzkhm +one7ninemdjznbqhfkckpjkxtwo12 +1bvjgdjlll +43kjdtwofiveseventhree9 +fourlgzcrldtwoseven9xndlqvbrtonennvlvzplrt +8twohzmcknlmqd +gshhvf5twodqgdseven8fourfoursix +nineone47sixeightrp +4stonekdgdhxrtqv9sixonevhhmhqzp +8lmpppc +4five8ffive +fivefivesmmkh6jhtggr4 +tjrr9ninenine +six6fiverqdlm67hztn2five +six3278xsddmnz +8qlhdpxn645nhrjm +xlfttcfs6jgtbeight6sixdvpl22 +87tcj6gkjfrrmdjbgh4 +6eightsevennmdpkkmkqrffgshrfhml7two1 +ninemglsrmvqrk5six +9nfgt1rntwo1826 +three2fiveonexrllxsvfive +9zjfkmdfbfqqf2mxpnqsmsthjzzszdxl +43eightnvdrthree1eightoneggrdmnp +pffldcmnlpsevensixqxhdncrclbc51five +5bqnlphone6 +195one diff --git a/2023/day01/solve.py b/2023/day01/solve.py new file mode 100644 index 0000000..b6a47c1 --- /dev/null +++ b/2023/day01/solve.py @@ -0,0 +1,24 @@ +def main(): + final_value = 0 + + with open("input", "r") as f: + for line in f: + line_strip = line.strip() + calibration_value = "" + for char in line_strip: + if char.isdigit(): + calibration_value += char + break + + for char in reversed(line_strip): + if char.isdigit(): + calibration_value += char + break + + final_value += int(calibration_value) + + print(final_value) + + +if __name__ == '__main__': + main() diff --git a/2023/day01/solve2.py b/2023/day01/solve2.py new file mode 100644 index 0000000..e545cf3 --- /dev/null +++ b/2023/day01/solve2.py @@ -0,0 +1,65 @@ +def main(): + final_value = 0 + text_digits = { + "one": "1", + "two": "2", + "three": "3", + "four": "4", + "five": "5", + "six": "6", + "seven": "7", + "eight": "8", + "nine": "9" + } + + with open("input", "r") as f: + for line in f: + line_strip = line.strip() + calibration_value = "" + + text_digit_pos_first = -1 + text_digit_value_first = None + for elem in text_digits.keys(): + pos = line_strip.find(elem) + if pos >= 0: + if text_digit_pos_first == -1 or pos < text_digit_pos_first: + text_digit_pos_first = pos + text_digit_value_first = text_digits[elem] + + text_digit_pos_last = -1 + text_digit_value_last = None + for elem in text_digits.keys(): + pos = line_strip.rfind(elem) + if pos >= 0: + if pos > text_digit_pos_last: + text_digit_pos_last = pos + text_digit_value_last = text_digits[elem] + + for index, char in enumerate(line_strip): + if text_digit_pos_first != -1 and index >= text_digit_pos_first: + calibration_value += text_digit_value_first + break + + if char.isdigit(): + calibration_value += char + break + + index = len(line_strip) + for char in reversed(line_strip): + index -= 1 + + if text_digit_pos_last != -1 and index <= text_digit_pos_last: + calibration_value += text_digit_value_last + break + + if char.isdigit(): + calibration_value += char + break + + final_value += int(calibration_value) + + print(final_value) + + +if __name__ == '__main__': + main() diff --git a/2023/day02/input b/2023/day02/input new file mode 100644 index 0000000..df90739 --- /dev/null +++ b/2023/day02/input @@ -0,0 +1,100 @@ +Game 1: 7 blue, 5 red; 10 red, 7 blue; 5 blue, 4 green, 15 red; 4 green, 6 red, 7 blue; 5 green, 8 blue, 4 red; 5 red, 4 blue, 3 green +Game 2: 8 green, 3 red; 7 blue, 6 red, 8 green; 7 blue, 3 green, 6 red; 8 green, 6 blue, 11 red; 6 blue, 3 green, 12 red +Game 3: 6 blue, 3 red, 7 green; 3 red, 3 green, 8 blue; 8 blue, 11 red, 4 green; 5 blue, 7 red, 6 green; 9 blue, 7 green, 1 red +Game 4: 3 red, 4 green; 5 red, 1 blue; 2 green; 3 green, 1 blue; 2 green, 1 blue, 1 red +Game 5: 17 red, 5 blue, 3 green; 8 green, 9 red, 10 blue; 2 green, 9 blue, 4 red +Game 6: 5 blue, 6 green, 3 red; 1 green, 8 blue, 12 red; 2 blue, 13 red, 6 green +Game 7: 1 green, 1 blue, 6 red; 1 red, 8 green; 3 red, 8 green, 2 blue; 14 green, 4 blue, 4 red; 4 green, 5 blue; 7 green, 2 blue, 1 red +Game 8: 6 blue, 9 red, 3 green; 2 red, 6 blue; 2 green, 1 red, 2 blue; 2 green, 9 blue, 6 red +Game 9: 5 green, 8 blue, 8 red; 2 blue, 6 green, 8 red; 6 red, 9 green +Game 10: 2 red, 2 blue, 12 green; 8 green, 3 red; 5 blue, 11 red, 6 green; 14 red, 1 green +Game 11: 2 green, 1 red, 1 blue; 4 blue, 7 red; 7 red, 7 green, 5 blue; 2 blue, 3 red, 6 green; 3 blue, 9 red, 7 green +Game 12: 9 green, 7 red, 7 blue; 6 green, 4 blue, 1 red; 3 blue, 5 red, 7 green; 9 green, 10 red, 12 blue; 11 green, 5 red; 9 blue, 12 green, 3 red +Game 13: 7 blue, 7 red, 2 green; 5 blue, 5 green, 7 red; 1 blue, 10 red; 11 red, 2 blue, 1 green; 1 green, 1 blue, 4 red +Game 14: 2 blue, 10 red; 3 blue, 6 green, 17 red; 3 green, 4 blue, 14 red +Game 15: 7 blue, 2 green, 4 red; 7 blue, 3 red, 3 green; 4 red, 2 green, 1 blue; 2 red, 9 green, 5 blue; 2 red, 4 green, 5 blue +Game 16: 5 blue, 1 red; 8 blue, 1 green; 5 green, 3 blue, 2 red; 8 blue, 2 green; 2 red, 2 blue, 5 green +Game 17: 2 blue, 5 red; 7 red, 1 blue; 2 blue, 2 green, 3 red; 3 blue, 2 red, 1 green; 5 green, 7 red; 6 red, 3 green +Game 18: 4 blue, 1 red, 14 green; 8 red, 4 blue, 14 green; 6 red, 11 blue, 10 green; 5 blue, 2 green, 3 red; 16 green, 10 blue, 2 red; 6 red, 4 blue, 12 green +Game 19: 10 green, 12 red, 12 blue; 5 blue, 12 red, 7 green; 15 red, 8 blue, 6 green; 13 green, 1 red, 10 blue; 4 blue, 8 red, 9 green; 16 red, 7 green, 3 blue +Game 20: 10 blue, 9 green; 9 blue, 1 red, 3 green; 11 blue; 6 blue; 8 blue, 10 green +Game 21: 4 blue, 4 red; 1 green, 3 red, 3 blue; 4 blue, 1 green, 2 red +Game 22: 5 blue, 4 green, 1 red; 14 green, 4 blue, 1 red; 4 blue, 4 red, 13 green +Game 23: 6 red, 8 green; 4 green, 1 blue, 7 red; 10 green, 5 red; 2 red, 9 green +Game 24: 1 blue, 10 green; 12 green, 5 blue; 1 red, 3 green; 2 red, 4 blue +Game 25: 2 blue, 3 red, 13 green; 7 blue, 15 green, 1 red; 7 blue, 2 green +Game 26: 20 red, 5 blue, 4 green; 1 green, 8 blue, 11 red; 7 blue, 6 red, 2 green; 4 green, 7 blue, 4 red; 5 red, 8 blue +Game 27: 3 red, 3 green, 1 blue; 3 red, 1 blue, 8 green; 3 blue, 4 red +Game 28: 1 blue, 15 red, 2 green; 15 red; 3 red, 2 green; 3 red, 1 green +Game 29: 4 blue, 7 green, 1 red; 5 green, 9 red; 8 green, 1 red, 10 blue; 2 blue, 1 green +Game 30: 9 blue, 5 red, 6 green; 15 red, 6 blue, 3 green; 13 red, 2 blue, 4 green; 2 green, 3 blue; 13 red, 8 blue; 5 green, 6 blue, 17 red +Game 31: 1 green, 9 blue, 9 red; 4 green, 8 red, 1 blue; 10 blue, 2 green; 1 red, 1 blue; 1 red, 1 blue; 6 blue, 9 red, 5 green +Game 32: 7 red, 7 green, 3 blue; 14 green, 11 red, 11 blue; 10 green, 7 red, 2 blue; 1 green, 4 blue, 4 red; 9 blue, 10 green, 5 red +Game 33: 12 red, 4 green, 11 blue; 4 blue, 10 red, 1 green; 7 green, 10 red, 16 blue; 15 red, 5 blue; 10 green, 4 red; 8 green, 5 blue, 6 red +Game 34: 8 blue, 1 red, 2 green; 3 green, 3 blue, 4 red; 6 red, 3 green; 6 red; 9 blue, 4 red, 3 green +Game 35: 6 green, 6 blue, 1 red; 3 green, 3 blue; 1 red, 5 blue, 2 green; 1 red, 13 green, 1 blue; 3 green, 1 red, 10 blue; 5 green, 4 blue +Game 36: 15 blue, 1 red; 2 red, 3 green, 17 blue; 6 blue, 7 red, 8 green; 12 red, 7 green, 14 blue; 4 blue, 2 red; 8 green, 12 blue, 10 red +Game 37: 2 green, 2 blue; 6 red, 3 blue, 1 green; 2 green, 3 blue, 1 red +Game 38: 2 blue, 7 red, 9 green; 3 red, 18 green, 6 blue; 6 red, 19 green, 2 blue; 2 blue, 13 green, 7 red +Game 39: 12 blue, 7 green, 3 red; 16 green, 6 blue; 1 red, 4 green, 2 blue; 15 blue, 2 red, 2 green +Game 40: 18 blue, 1 red; 4 green, 15 blue; 5 green, 17 blue, 3 red; 4 red, 16 blue, 2 green +Game 41: 3 blue, 14 green; 11 green, 8 blue; 14 blue, 4 red, 1 green; 5 blue, 2 red, 15 green +Game 42: 7 red, 9 green; 10 red, 19 green, 10 blue; 16 blue, 8 green, 7 red; 6 blue, 11 green, 7 red +Game 43: 1 blue, 5 red; 8 red, 2 green, 1 blue; 4 red, 3 green; 2 green, 1 red +Game 44: 5 green, 13 blue, 12 red; 18 blue, 3 green, 8 red; 2 green, 3 blue, 11 red +Game 45: 3 blue, 1 red, 4 green; 2 blue, 1 red; 1 blue, 4 green; 3 red, 16 green +Game 46: 10 red, 1 green, 4 blue; 4 green, 14 blue, 2 red; 12 red, 3 blue, 2 green; 4 green, 2 red, 2 blue; 2 red, 1 green, 11 blue; 2 green, 19 blue +Game 47: 10 blue, 10 green, 3 red; 3 red, 11 blue, 9 green; 4 blue, 10 green +Game 48: 5 green, 1 blue; 4 red, 8 green, 8 blue; 17 red, 5 blue, 2 green; 12 green, 18 red, 7 blue; 15 green, 14 red, 8 blue; 11 green, 1 blue, 16 red +Game 49: 2 red, 4 green, 1 blue; 1 green, 5 blue, 2 red; 8 green, 3 blue, 1 red; 4 blue, 3 red, 9 green +Game 50: 2 blue; 7 green, 5 red; 3 red, 3 blue; 5 green, 1 blue, 2 red; 5 blue, 3 green; 4 green, 3 blue, 1 red +Game 51: 6 green, 13 blue, 3 red; 7 blue, 7 green, 1 red; 15 green, 2 red, 13 blue; 1 red, 7 blue, 3 green; 11 blue, 16 green, 1 red +Game 52: 5 blue, 2 green, 14 red; 4 blue, 3 red; 10 green, 7 red; 1 blue, 10 green, 10 red; 9 blue, 5 green, 12 red +Game 53: 1 green, 2 red, 1 blue; 4 green; 1 green; 2 green; 2 green, 1 red +Game 54: 3 green, 11 blue; 12 blue; 1 red, 3 blue; 7 blue, 1 red +Game 55: 7 green, 7 red; 1 blue, 7 green, 14 red; 17 red, 2 blue, 5 green; 1 blue, 7 red; 2 blue, 3 green, 14 red +Game 56: 3 blue, 2 red, 1 green; 1 red, 4 blue, 2 green; 5 green, 1 red, 2 blue; 7 blue +Game 57: 1 blue, 14 red, 7 green; 2 red, 1 green; 1 blue, 6 red, 6 green +Game 58: 11 red, 2 green; 3 green, 8 red, 8 blue; 10 red, 1 green, 13 blue +Game 59: 11 green, 5 blue, 11 red; 13 red, 6 blue, 11 green; 6 red, 7 blue, 12 green; 9 blue, 9 red, 1 green +Game 60: 3 red, 8 blue, 4 green; 5 blue, 2 red, 3 green; 7 green, 3 red; 8 blue, 2 red, 7 green +Game 61: 17 red, 12 blue, 9 green; 20 green, 5 red, 14 blue; 9 blue, 11 green, 15 red; 14 green, 6 blue, 14 red; 16 green, 7 red, 4 blue +Game 62: 3 red, 11 blue, 16 green; 1 green, 6 red, 6 blue; 7 green, 6 red, 9 blue +Game 63: 3 blue, 20 red, 1 green; 11 red, 5 green; 13 red, 2 green; 15 red, 1 blue, 6 green +Game 64: 8 blue, 1 red, 11 green; 1 red, 11 blue, 4 green; 5 red, 7 green, 1 blue +Game 65: 3 blue, 13 green, 2 red; 2 blue, 3 red; 10 green, 8 blue, 2 red; 2 red, 6 blue, 8 green; 10 blue, 12 green +Game 66: 4 blue, 3 red, 8 green; 1 red, 9 green; 7 blue, 6 red, 6 green; 1 blue, 1 red, 11 green +Game 67: 10 blue, 15 green; 3 red, 2 blue, 1 green; 4 blue, 12 green, 2 red; 8 green, 11 blue, 8 red; 9 blue, 5 green, 6 red; 10 green, 4 red, 14 blue +Game 68: 4 green, 3 blue, 4 red; 9 green, 2 blue; 6 blue, 6 red, 10 green; 5 blue, 4 green, 5 red; 3 blue, 10 green; 5 blue, 5 red +Game 69: 6 blue, 1 red, 1 green; 4 red, 3 green, 2 blue; 5 green, 3 red, 5 blue; 5 red, 5 blue +Game 70: 2 green, 1 red; 12 green, 1 red, 11 blue; 7 green, 12 blue; 13 blue, 10 green +Game 71: 9 red, 9 green, 4 blue; 10 red, 1 blue, 12 green; 3 blue, 13 red, 3 green +Game 72: 2 red, 8 blue, 5 green; 2 green; 1 red, 5 green, 6 blue; 1 blue, 3 red, 12 green; 5 green, 14 blue, 1 red; 8 blue, 13 green +Game 73: 19 blue, 11 red, 8 green; 18 blue, 9 red, 11 green; 6 green, 19 blue, 6 red +Game 74: 2 green, 4 red, 2 blue; 1 green, 1 red, 4 blue; 2 red, 4 green, 2 blue; 3 red, 2 blue, 6 green +Game 75: 2 blue; 1 red, 1 blue, 1 green; 1 blue; 5 blue, 2 green; 1 green, 1 red, 3 blue +Game 76: 9 blue, 4 red, 3 green; 8 blue, 8 green, 3 red; 3 red, 2 green, 8 blue; 8 green, 6 blue, 5 red +Game 77: 7 blue, 17 green; 1 blue, 2 red, 18 green; 18 green, 1 blue, 2 red +Game 78: 2 red, 2 green, 1 blue; 5 green, 3 blue; 1 green, 2 blue; 2 blue, 6 red, 5 green +Game 79: 4 red, 6 green, 17 blue; 2 blue, 3 red, 8 green; 8 red, 19 blue, 12 green; 5 red, 8 green, 12 blue; 16 blue, 1 red, 12 green; 5 green, 18 blue, 8 red +Game 80: 1 blue, 4 red, 10 green; 6 green; 6 red, 3 green, 2 blue +Game 81: 2 green, 5 blue, 4 red; 3 red, 1 green, 14 blue; 3 red, 10 blue, 2 green +Game 82: 12 red, 5 blue, 2 green; 12 blue, 6 red, 5 green; 13 blue, 1 green, 3 red; 11 red, 3 blue; 4 red, 3 green +Game 83: 10 blue, 16 red, 4 green; 6 red, 2 blue, 14 green; 9 blue, 14 green; 7 blue, 1 red; 4 green, 2 red, 8 blue; 5 red, 7 green +Game 84: 3 red, 3 blue, 6 green; 9 red, 17 green, 16 blue; 13 blue, 7 red; 14 green, 2 red, 14 blue +Game 85: 7 blue; 8 red, 10 blue, 1 green; 6 blue, 9 red +Game 86: 9 red, 6 green, 9 blue; 1 blue, 5 red; 11 red, 1 green, 11 blue; 3 green, 8 blue; 8 red, 5 green, 4 blue; 15 blue, 4 green, 2 red +Game 87: 2 red, 2 green; 5 red, 2 blue; 6 red +Game 88: 2 green, 5 red; 9 blue, 7 red, 3 green; 1 blue, 2 green, 3 red; 3 green, 6 blue, 1 red; 1 red, 3 green, 6 blue +Game 89: 10 blue, 13 red; 15 red, 6 blue, 2 green; 2 green, 10 red, 18 blue; 1 green, 18 red, 8 blue +Game 90: 2 red, 2 blue, 9 green; 1 red, 9 green; 7 green, 3 blue, 2 red; 4 blue, 2 red, 4 green +Game 91: 6 green, 4 red, 9 blue; 4 green, 4 red, 17 blue; 6 blue, 2 red, 4 green; 7 green, 2 red, 13 blue; 1 green, 13 blue, 1 red +Game 92: 4 green, 1 blue, 8 red; 7 green, 6 red; 13 red; 9 green; 6 red, 1 blue, 4 green; 2 red, 1 blue, 15 green +Game 93: 8 green, 8 red, 13 blue; 4 red, 10 green; 15 blue, 11 red; 14 green, 5 red, 6 blue; 12 red, 3 blue, 13 green; 9 red, 10 green, 6 blue +Game 94: 14 red, 10 green; 15 red; 4 red; 4 green, 7 red, 1 blue; 6 red, 5 green; 1 red, 2 green +Game 95: 1 blue, 11 red; 15 red, 1 blue, 3 green; 13 red, 2 blue, 3 green; 1 green, 1 blue +Game 96: 4 red, 4 blue, 4 green; 5 blue, 5 green, 4 red; 2 red, 8 blue; 16 red, 5 green, 13 blue +Game 97: 6 red, 13 green, 3 blue; 10 green, 4 blue; 3 red, 12 green, 4 blue; 3 red, 5 blue, 16 green; 3 red, 9 green, 1 blue +Game 98: 8 red, 12 green, 2 blue; 7 green, 8 red, 1 blue; 2 blue, 6 red, 3 green; 9 red, 1 blue, 4 green +Game 99: 6 blue, 11 red, 7 green; 9 red, 6 green, 1 blue; 9 red, 2 blue +Game 100: 1 red, 4 blue, 2 green; 6 red, 2 green, 11 blue; 1 red, 1 blue, 2 green; 1 red, 7 blue diff --git a/2023/day02/solve.py b/2023/day02/solve.py new file mode 100644 index 0000000..939b134 --- /dev/null +++ b/2023/day02/solve.py @@ -0,0 +1,24 @@ +def main(): + max_seen_colors = [] + id_sum = 0 + + with open("input", "r") as f: + for line in f: + current_game = {"red": 0, "green": 0, "blue": 0} + line_relevant = line.strip()[line.find(":") + 2:] + for grab in line_relevant.split("; "): + for items_saw in grab.split(", "): + count_and_color = items_saw.split(" ") + current_game[count_and_color[1]] = max(current_game[count_and_color[1]], int(count_and_color[0])) + + max_seen_colors.append(current_game) + + for ii, elem in enumerate(max_seen_colors): + if elem["red"] <= 12 and elem["green"] <= 13 and elem["blue"] <= 14: + id_sum += ii + 1 + + print(id_sum) + + +if __name__ == '__main__': + main() diff --git a/2023/day02/solve2.py b/2023/day02/solve2.py new file mode 100644 index 0000000..c79821a --- /dev/null +++ b/2023/day02/solve2.py @@ -0,0 +1,23 @@ +def main(): + max_seen_colors = [] + power_sum = 0 + + with open("input", "r") as f: + for line in f: + current_game = {"red": 0, "green": 0, "blue": 0} + line_relevant = line.strip()[line.find(":") + 2:] + for grab in line_relevant.split("; "): + for items_saw in grab.split(", "): + count_and_color = items_saw.split(" ") + current_game[count_and_color[1]] = max(current_game[count_and_color[1]], int(count_and_color[0])) + + max_seen_colors.append(current_game) + + for elem in max_seen_colors: + power_sum += elem["red"] * elem["green"] * elem["blue"] + + print(power_sum) + + +if __name__ == '__main__': + main() diff --git a/2023/day03/input b/2023/day03/input new file mode 100644 index 0000000..e51b04f --- /dev/null +++ b/2023/day03/input @@ -0,0 +1,140 @@ +.......497...........................858...923...128..................227..801........487.....664........................................... +436........765..............140.......+....................859.............*.........+.................960........668....................... +...*982...........=..........=....203......266.263...375*....=...402....691..-....................*..........575....................13...... +.............114...588...............*............*......631........*.......952...463..14.......661..........=...706......*333.........595.. +...194.........*..............743...917.&......375.....................................*...............544*.......*....664.................. +...*.....807..452....81..........*......969..#......309*................/....873....941...828.197..........427.728...............566...13... +.243........*.....80.......329....470.......145.475.....111........*659..259....+........*....%........569..............%.....*....*....*... +.........130......*....385*............123......................199.......................640.....463..%.........978....920...266..380.83... +.....323........870.........+...........$.........466......453........................297...........*............*.......................... +........*.=..............588.....*786......$.........*........*.......390*.....886...*....227...728..852.......606....*863.......916..396... +.....538...287................301........133.....539..........33.537......466..$...793..+..........*...............218.....721........*..... +...............986.........=.......................................*...%...............222..-.......701.271...............#.........437..... +......*3.........*.626.68...419...740...........................806...976.......875.........174..............735.............=488........... +...790.........487....*................./532..13............................*....-.....503..........*11..734..........978.19......622....... +...................&....712.68=.619+.........*.......................863...596.....2.....*.......160.....+...&659........*.........-....-757 +437*.......#........520...*..........304....568.974.255.318.183.........*.......&.....675......................................849.......... +....161.....687.710.....854.............*.......*......*....&...441......891.....476..........616.......$........235..434.880...*..673+..... +..................*...............683.....800.120..............*....807..................................707.....*....-....*...74........562 +....@...#988...487..#685..........-......*..............251.146.............................142@....74...........398....769..........238*... +....848....../................-.$.....662.........773..*...........895.......591...........................233.............................. +797.........611..........@.186...429..........304*....468.....554....*..........*...960......82.......*810...+.534..660....645...313./...... +......239..............509...............720*......................844..939=..508......*...........401............*.......*.......*...649... +........=........158.......$.....=...........200......409....982.....................46................126.....517....303.647.660........... +...530....=......*..........704.69...................*.......*..................@879........589..131.................*........*............. +......*..871...672....................611*........415.......283.569.21....842/........-109.&.......*.......157$...719.......679.$........... +....664..............664......668.........203....................&...%............................14..................427.......833..484.... +....................*........*.......434.......796...........65............................................-479.126..*..............+....... +.....382..........121.....836.........*........@...............*789.......624........350&..........*544............$.6.........882....513... +....%.....406.........................848........625...%...88.........382..+..971.................5......*622...........914....*....%....... +..............627....816........641..............*.....373./.............*..../...912..651.162........557........901...&.....503.337....59.. +...357...........*.........552...*..816..........240......................636.....*...*.....*.............@..993....*....................... +......*934....961...=..43..*...324.....@...............726.888....370...........170.805...517........639.389....*..929.................953.. +.16...............408.*...94..................................*......&..............................*......../...9........605............... +.......571....13......512........591+.......976.......895....489...........751.......474.760.........240.....931............*............... +...464../..................608..............*........*................$.94*........................................486.......172............ +...*......121........=.....*.......$......909.......583............128........929...................765.............*............+....24.... +.............*.......762....230..422..285.....434......................390.....=.....921.................261....#...949.....382...903.*..... +............595........................*.......*...................833*..............%.......973..$....@...*.268........506*..........251... +967...................................25....234...........................306....281..........=..36..918.432....../406........344...$....... +.....700*610.......=...839......917......33......610@................537....=....@............................%........20.402.@.....926..... +..............%.768...*....................*...@............93..161.%...............74$......%.........96..298..........%..+............+519 +...........925.......586...................264..85...721....*...*.............................371.................822.=..................... +...............540...........-....447....................987.....305.............379@.707..............670...397...*..842....552.464........ +.....666......*....844....515.......*..............+114..............977...............&...393........*.........$.800...........*........... +.....*...647...696..*..............203....................418.....19............522........*.......462................57...786..........561. +....691.....$.......756...165.....................596.32...%........#..280.259$..........398..............425.............*....719..796..... +.............../.........=........1/..305............*.........451......&..........332.......706............&.......327.841...........*..... +.74..........791.............=........+.....................+...-..................+..........*.....................*...............419..371 +...*927..........352.......148..........401....459...+....998......$783........@............444..$.......959..106.366....................... +............190..........*......385.............*....846......................907.826..585.......447.441..*..*............7......871........ +.................142....944....$.................634.............587..@..930..........*......935.....*...819.29.....3......*35.............. +......967....415*......................=980.....................%....58.-......317..74......../.....922..............-.207........../....... +.........................................................................................................175....................369.233..... +.........................+....645.$........%.....620.+429....951......616.................................*............524$................. +....799...551*602........920..+....503..654....-...*............*....=......395.........451....263.......897..................370........... +......-.......................................409......970....661.............*............+...*....48...................475..$........839.. +..97...................../.....@497....%..........446$...*...............533..794.....432-.....167...*.....722...486........*...500...*..... +..............459......540.............110................569............&..................#.....................#........785.*.......455.. +........815....*...........................*452......./......................365.........929....*978.=................709........+..84...... +....427*......466.............608*796..............680......................*......&.........142.....603.................#......621..*...... +.........635............@....................302..................296-.....679...801..290..................464..............980......627.... +....../.../........%...850.......*108....513*........656...*739........715...............@.......713.......*...................*............ +354+..245.......629...........995.....................$..41.....=.....@.....................45..........840......506+...$.....148........... +..........995.................................&541............914.510.....950...../...........*53..28...................275........138...... +.............*812..665...../.........................101.308..............*......691.482.............*........902.585.......@.......*....... +.........../........./...292...............#..........-....*....@307......661..........*.210......135....932%...........992..54..191..931... +...400..649...............................504.196.........88........................581.............................743*.............&...... +...*.........140..............642....891.............309...............................................695......361..............603........ +....170.643#..*.................*....*.......*24.....*....................932.291.....538....461.........*........*..275............&....... +.............725......494......23...279...713..../....449............*........*...../...=......*..........434..............785.............. +.....991..........946.............................830.........136.439.24...519......289.......408...579........708.650*......*.370.13....410 +......*..887........#..688.673.........218......................-...............941....................$.......%.......927.722....*......... +....124....*...........*..../....427....*.............312................................................922...........................307.. +...........706...16..934..*.......*......608....459..&..........761.....................647..641...........*.............242............*... +..5*715..-........+........122.....262........./...........928....%............728..610*......*..502.....222..40.....923..+...........540... +.........701.............=..............291...............*.........351.........*............141.%............*.../.....*....725............ +..............314.......878....%.......*......=..820*.....988..204.....-.....889......119............797...........395....+.............287. +..................671........322....101......257.....733........@.....................=.............*..........544......600.......862....... +..421.......582...%..............................484...............565.....+...831...........695...384.#...592.=............240....../.904.. +....*..........*........570...........&....=........*629......717&.*.......93......726../961....*......535..*........767../......715....*... +....439.....630............../..%...615...912......................777............*..............602.........567..3........107....$..77..... +....................914.....3...2.=.............763...&885......................185....182.......................*......-......+............ +...372...383........*..............60.............*............&..38.681...............*.....459....../........117...504......358..480-..... +............+.990..33...........................834.......@..33......................494....*........181.66+................................ +...............*......*...492..............176..........857...........376.315................954.....................*982.......763......... +329=..........179....245...*...61...........*...*................%......+....*.....352*509.........952#..69..620..423.............*......... +.........................131.....*17......191.33.306...../.....144..503......491.............................................298...415...... +...................$...................................426.........*...............526.669.....&498..698...$............447.....+........... +.............575...142.617......890..............%...............212..730.519.971..&......*384.........@....18.219.........*................ +.......*537..*.........*........*.........677...587..407...120*........./....*...................................+......334..........700.... +....944......636..848........743.....388..*....................109..........................................................540.40..*....... +.................*....596............*....155..324...820.520.................=...............443...94...........621.276......*..+..910...... +...............276.....-.........376...........*........*....................739......368....=..............428....*......434..........878.. +932....28.....................-..=....207......959....................289.........196.*........................*...............-.......=.... +...*........................172....#.#.....688.........25..944...725...&............*..110.....148...426.483..771../932......800............ +.947............................457....931*.............-....*...#.......834......721.........*.........*.............................477... +.....*491......*.........*114.................191.....$...213........909*...................194............633....%...792..605.633...#...... +.............108......611.....+719...........*.....696........865...............120................=724...%....950.../......*...../......... +...320............*.................260/...121.........338...*........719.180.........516.....*.............................649............. +.....#...643.......941......*160......................*......140...94....*...............*..39.789................*......&.........81...597. +............*..135.......532.................%90...608............*............+515....743.............+...194.993.669..259..+.............. +.....%....948.....*............262..695.712....................623.....*...................473........602...*...............83......679..... +..259.............447.............%.*...............363.............105...................@........=......+.........................*....... +......957....659........299..........................%...599..898.+.................464.......606.237..768..416@....=...............228..... +.376..$.........*..........*..2.........@557......./.......*.*.....517..........859*.........*....................855...877.427.........*... +.........*468..535......500....$................117......726.381........428...$................@........43....472.......*...*...........476. +......517................................951........%............-..249..@.....920...........859........*........*....825.393...15.......... +...........770.......&16.....278...417......$.....626...-23....954.....#..............................868.......502............*............ +.....373..*...................%...*.....254................................................246.#530....................982....179....635.... +......*...538.....................362...-...........162.........................180=........*..................278.......*............+..... +....138.......922..............................543................6....12....&.............92...150...............*.......994............... +................+.....+................388....*..........................*....788............../..................220.............834....... +.....................301.593.597.............500..603......928....966................/.............536.......768.............800............ +................*64........*.../..&.....924.........*........-...$....................203.............-...+..../...............*..423.&451.. +.............453....*......638.....314..*...896....459...............96...................186............581................846....*........ +....&188.........624.400...............268....@...........................664...............*...12.943............#733...................... +.............................597...765................388......149..468.....+............698......*....143........................426....... +.......................878...*.........875..............*..871*.....*..............929....................$.504*..............473.%......... +...245..........94.651..*.....915.........*.........40.440........236.................*511.45........994........753..................887.... +...#..............*.....459............212...18*964.*.........=71..........768..827............./.....*......................567............ +.....787.2..781*....................................827....................*...*..............437.....813.......317.....102.....*333........ +..........*.....285............@..-...........304.......821.622.....953...377.997......320....................@./.....%....*..........254... +.......877..636.....42......772..419.....189..*................&....*.....................=.17......366*....563......228...153.............. +...............*.....$................&....*...839......218.........449......................*..409.....69............................652... +.....576......255..............593...397............469..%......#.......+568.......374......499....*...........541..477.........%137..*..... +.......*............@319.................$.35..........*.....207...............808*.................933.737...........*.502............367.. +.....807....219../.....................436......226@...266........215...................................*................................... +..............*...769.....41*....922............................$..*.......271.........350..........677.346......................662....725. +..............175............979.*...#........215..............652..39......$....=61......*..154...................................*........ +...426..............335*.........487.194.........*42...................790.............+.750.@......&..............253...337....617..717.... +...+....908.............489.................../............14...278.../....953.......316.......*856.44.50...../.......*................$.... +.........%..90.................437..........848...........................*......714........708..........*223.588.....884....871.801........ +494@..........*..33...........*.........779.....424.550....923............779.......*...340........738.......................*....*..131.603 +.....50..481.........=.....643...........@......%............*.......815......681..263....*........*...5.....256*11.377$....872.903.*....... +.....*...............635.......698..........583...148........708........................323.243..201.....................*..........377.132. +...502........883............/..*..............$...*....994.........*....479@.................$......804.443..........584................... +.............*..............893..581..534........376..+..........174.119.........138............670...*....$.834............4............... +.....+....234...904.323..=..............&.894..........439.@838............*.....*........47........555........*............*........932.... +...594............*...$.654.....+.........*........................84.*....7...231.$102.......286.......*760....817.......719.........*..... +..................620............806......866.................559......440...........................310...........................590..547. \ No newline at end of file diff --git a/2023/day03/input_test b/2023/day03/input_test new file mode 100644 index 0000000..624ea4f --- /dev/null +++ b/2023/day03/input_test @@ -0,0 +1,10 @@ +467..114.. +...*...... +..35..633. +......#... +617*...... +.....+.58. +..592..... +......755. +...$.*.... +.664.598.. \ No newline at end of file diff --git a/2023/day03/solve.py b/2023/day03/solve.py new file mode 100644 index 0000000..bc84dc0 --- /dev/null +++ b/2023/day03/solve.py @@ -0,0 +1,46 @@ +from typing import List + +def is_part_number(lines:List[str], column_count: int, row_pos: int, column_start: int, column_end: int) -> bool: + min_column = max(column_start - 1, 0) + min_row = max(row_pos - 1, 0) + max_column = min(column_end + 1, column_count - 1) + max_row = min(row_pos + 1, len(lines) - 1) + + for row_idx in range(min_row, max_row + 1): + for col_idx in range(min_column, max_column + 1): + char = lines[row_idx][col_idx] + if char != "." and not char.isdigit(): + return True + + return False + +def add_if_part_number(result: int, lines:List[str], column_count: int, row_pos: int, column_start: int, column_end: int) -> int: + if is_part_number(lines, column_count, row_pos, column_start, column_end): + result += int(lines[row_pos][column_start:column_end + 1]) + + return result + + +data = [] +with open("input") as f: + for line in f.readlines(): + data.append(line.strip()) + +result = 0 + +columns = len(data[0]) +for row_idx, line in enumerate(data): + number_start_idx = -1 + for ii in range(columns): + if line[ii].isdigit(): + if number_start_idx == -1: + number_start_idx = ii + elif number_start_idx != -1: + result = add_if_part_number(result, data, columns, row_idx, number_start_idx, ii - 1) + number_start_idx = -1 + + if number_start_idx != -1: + result = add_if_part_number(result, data, columns, row_idx, number_start_idx, columns - 1) + +print(result) + diff --git a/2023/day03/solve2.py b/2023/day03/solve2.py new file mode 100644 index 0000000..5b23f13 --- /dev/null +++ b/2023/day03/solve2.py @@ -0,0 +1,104 @@ +class Gear: + def __init__(self, line_idx, column_idx): + self.line_idx = line_idx + self.column_idx = column_idx + self.connecting_parts = [] + + +def add_part_to_gear(line_idx, column_idx, part_number_line_idx, part_number_column_idx, gears): + for gear in gears: + if gear.line_idx == line_idx and gear.column_idx == column_idx: + gear.connecting_parts.append((part_number_line_idx, part_number_column_idx)) + break + else: + new_gear = Gear(line_idx, column_idx) + new_gear.connecting_parts.append((part_number_line_idx, part_number_column_idx)) + gears.append(new_gear) + + +def check_if_part_number(line_index, column_index, lines, gears): + ret_val = False + + current_line = lines[line_index] + if column_index > 0 and current_line[column_index - 1] != ".": + if current_line[column_index - 1] == "*": + add_part_to_gear(line_index, column_index - 1, line_index, column_index, gears) + ret_val = True + + max_column_index = column_index + for index in range(column_index + 1, len(current_line)): + if not current_line[index].isdigit(): + break + max_column_index = index + + if max_column_index + 1 < len(current_line) and current_line[max_column_index + 1] != ".": + if current_line[max_column_index + 1] == "*": + add_part_to_gear(line_index, column_index + 1, line_index, column_index, gears) + ret_val = True + + min_other_column_index = max(column_index - 1, 0) + max_other_column_index = min(max_column_index + 1, len(current_line) - 1) + + if line_index > 0: + other_line = lines[line_index - 1] + for current_column_index in range(min_other_column_index, max_other_column_index + 1): + other_char = other_line[current_column_index] + if not other_char.isdigit() and other_char != ".": + if other_char == "*": + add_part_to_gear(line_index - 1, current_column_index, line_index, column_index, gears) + ret_val = True + + if line_index + 1 < len(lines): + other_line = lines[line_index + 1] + for current_column_index in range(min_other_column_index, max_other_column_index + 1): + other_char = other_line[current_column_index] + if not other_char.isdigit() and other_char != ".": + if other_char == "*": + add_part_to_gear(line_index + 1, current_column_index, line_index, column_index, gears) + ret_val = True + + return ret_val + + +def main(): + lines = [] + positions = [] + gears = [] + with open("input", "r") as f: + for line in f: + lines.append(line.strip()) + + part_numbers = [] + + parsed_number = None + is_part_number_parsed = False + for line_index, line in enumerate(lines): + for column_index, char in enumerate(line): + if not char.isdigit(): + if is_part_number_parsed: + part_numbers.append(int(parsed_number)) + + parsed_number = None + is_part_number_parsed = False + elif parsed_number is not None: + parsed_number += char + else: + parsed_number = char + is_part_number_parsed = check_if_part_number(line_index, column_index, lines, gears) + if is_part_number_parsed: + positions.append((line_index, column_index)) + + if is_part_number_parsed: + part_numbers.append(int(parsed_number)) + parsed_number = None + is_part_number_parsed = False + + gears = [gear for gear in gears if len(gear.connecting_parts) == 2] + ratios = [] + for gear in gears: + ratios.append(part_numbers[positions.index(gear.connecting_parts[0])] * part_numbers[positions.index(gear.connecting_parts[1])]) + print(sum(ratios)) + + +if __name__ == '__main__': + main() diff --git a/2023/day1/input b/2023/day1/input deleted file mode 100644 index 6edee3a..0000000 --- a/2023/day1/input +++ /dev/null @@ -1,1000 +0,0 @@ -two65eightbkgqcsn91qxkfvg -neightwompstbkqv1fourfthdcfgtrkqzgrbfrczxbdn -43qsrrlxxq -898dbpjmdqjgtrvdvlxxdnvlfhncdzrt -jninedsrvftdlcg4hhztwofourskrjhcjvthree -five562 -bpnjmtmeightninesix2391 -rftqshh47n -ctpkqsdqz97zqptzjlfbtwo -sjtwonesix6cqbv4 -9zclhrrssvzpcfpqlshfsxs -ninemcctrb5glhmctwol7 -eight5fourtwotwo -18frdsvjxdpxf8dxsevenm -five55foureight -dbqeightwo4sxzsix -ftjjqbgphtmhthreesix1six -8sczkklgr5ncxkhkq -126dzbvg6two4oneightntd -fiveqcplndmmcsixksmmpdqgttwosixnine7eight -eightseven5threesevennine -nmxmcvrzbcppktgbznz2 -five83 -57rqxmvf12 -4nklcvfsix1jvsvxh8nine -tpjppv6seven4sixsevenvnhcxonefjztthdcv -dfkcrcfxkmxccpf7sixkzlgf -ninetwo6hfg -9sfiveffxqthreeqlvhbvrpbd -gtcmqsheightthree51eight -lhszhqvtn12three8xvfglffivekc -hntwone2cmgppck5oneonesevenone3three -8414onehlxjfqghrklv -cdtlrnine2onexfspkgltjrbone8 -tsjvxqljbfivefive11fourfour1st -dhhrftncnttrqz21fbdkkcdbndmdrp -jsfcqhzstnxxlchnxlztwonine5 -twothree2nhjzlhqdlgnplkjts7 -7zndkjxcp4xvqmqlgrhg -446sixqtk5fiveoneeight -3hdqtn2kjdkbzxx -onethree8ninelggjk38xt -2bdnkxoneeightonetskninefive -xcxfqtnpnmdmtrfivefour1seven -1cf -onefive5 -t5dnseventhreehbvkqzhbbttvd -49kdxj -s743dflzcsfninefour8 -eighteightfive7 -2zjsxntjfbkc15vtfkltb7 -knkmdgggk95two2 -dvjdztx6kfzzsscfcj6zz -xvcnqppc4five7threethreeckhtmfeight -4eightthree9onexmrhrfzjjjmfm94 -threebr7 -four188nine856 -szseven9269 -rppvmpprsgqbvbskg8fivedgpv5 -992one -fxthfh9twothree -jldmzlktzbhlsrndvn398five -vdzhddpsix6sixsixvbqmf8mrgnqxsxvxvdcdzmkc -7tv9 -37seventwofour -seven1six723 -nxjlgr64tjlqzphzjdvgb1nd -zmxldpjdsixvzcmrxxzl6 -91cgn9eightzxdzfmj -skhtxclf2ninemqct -foursixn8two7srvbbdldpbtwo -two5gpnnhtseven -onepqmzphpgfive2three -5vrgsfbj -5xmqhfbdt965 -263nzqjrklqkgtcgjcnprgtfj -78qrpdzmczxj7fourone2 -6threed -eight2twogr -96five -2ndkfivetwo6 -41fourckqxpdxdctnqmljkrl -68fzpjjvfhjv4fourhsvqtwo -ffqnvbxdzxhsxg9sevenkhpmnflbgfqsvfzfmxnlfcq -eight1six38one8g -5xhdtqshnc9foureightwog -two9llmcgxhjdghbv -9twoeightsix -f4qmsfgvzxfvxgq33twocmfnd -vqq8two8nhsqpgqnzrsixsix -dbxfbl98nllgpsix7 -svzgxfspxjfbcvonefour4 -eightonefour3nine8 -tqhgbkzmhseven656tczxkfkztwo -pckdctnzvxdgz4 -5pg -7two7vqtqxmddlbhppmpx8kldcgcfeight -gdbmfmppzl96452 -rpnmhfzclkmftsjkpone4sixmjhbjprx -16ljkbvbbc77sixvjlcpdqkvkcrfqslfzvtrqf -4threetwonedrd -seven5mqgztxfqdfdssbc -6eightsixpb -7jqktjqrthoneeightthreeqpssplvh669 -fivekjfktwo21jgtjdxeightseven -cjfvqzvtsstsvqsdgzlcrqnmmkgtvlclhfddeight6 -8247819snr -684 -threedqsvxzfmgrbrtjmjtzjeight57 -1three1233tvbpqrlrpz -bxlljzgmc4twothreenldkshgt -eight9dmzftbzmsgmxvhx7khsgvgmbgg -threehbvlqone9sevenxbccbppjxj -jthreesixqlxlvtwo8 -cg5nineonejtmpthkqncdmcrjztml -six69sixone5fourvhnzkxqrkm2 -mkpqfbjrninemvngbxl1nine5seven -qgxhthreetphvh4fh -four84 -8cdhf9fivexqsxljf -eighthmfq788eight -sevenktvsvvxj8fourgdbnpnthreethreenine1 -zlcmzfsxdvthree6 -mscdeight3 -lhzcxzthree8seven87 -rnrldrcponeqfdlxgz1lpxtf23sixkdqz -6fiveeightsixthreefour -onetwo1nine5gsvbzlsfrp4 -fivefivesix82qhdhnxbgmbttgdqq92 -jk886lfour -kcqmt6qk7gcdzzzzdljdmh3nineshcfnbnnd -sevenfour2krdvsfour -kbvlbhfbjqnr9three -two17 -dlvndnhdbjgtp57 -pqvxgonesix8k72pfmsjl -eight7xq3 -xgzxgtfqvsvvtfr23fzkvphdjmm -8hbkggrpxq8two3fivefour8six -tcxntnppqtbflnzfour6zzgrpvxjtf -2sevenninefive5 -sdvxrpt5lhzmkknseven2one9 -7pcpmgghrbt1zpllhshcsnine -cf8 -mfxnmj2ninesix58eight58 -8hfnnclmmsg64scdrtdkfivetwo -9four1sixj1three -7nrcxngrxxsixmccsb4rhztxmklmccpttwo -jgtdvpseven7two59 -369seven -onegdlthd9one8sixseventhree -6eight9seven -94five -6one282three9one -7rgxznfbf -zrtoneight9sfnsixninesevenzvqdxqjrcdm -five6sixkxksxone3six -qjqrjkjvplkxqvthree58ktgq -7kkc -hr54pmdtnpvzrlskpqrrqhbrnzz -99sixfgnfour389one -ltteightwothreefourfivenine7 -kzpzschjsptdpd6fiveninemxfxlkbmfl -eight7dqpvvplkjxgrxxtvt -41nine -61 -5qfneight7bhhnine8eightoneightfrx -34cjbcqzeighttwoqfdtqtqbl1 -twofivehbxftnsixhtffgqksdseven6 -84mnkvppxk18 -62four6rsph -8fourctcnnzfz -5jngcrllpnonefive -grmspdlkv42tdzctls -67sixeight1 -ninetwo52 -9jdvzhzflgxmsixzklv4cldfivetdmhrlm -eight7twoghldrbzhleightjs -ninenp8 -jxqjeight48qljhkkbfctonethreejfqlr -z9lxzgzkbmr7jtgpczmvblfour1 -545two -56tkxjhndzmtwofour -1ninesixpxxxlfnfn -6threesix9twojrmtl4 -6rjzjlxh5tdfkbjzvm -g8one7ccsix -4jxhxrgrhxv6threegkdsgvzxpzzrjclzrn5 -qhdjbsh5 -8mmngf4lpngqnbtxz -zstqrl5sevengcndbztdcr -mmdsseveneightfdbthreezbqkdbb3 -kkntgp94937 -2zrzntn8three -klklfnxcnmczrjlprktwo55 -7ninecqjtkjsdkqgqvcxtcone6 -bgjjheight5txcsjbvv1 -rqbk4 -soneight2qxbfdkdn51ttfourfiveninesix -czxhmh73llnlspseven8hfqzdpdqmg -26zmphsljkkddzbkninesixnine7 -45six -9f -6five6nine2sevenzzzmvzlh -hfnfour8blpsixvhdz26twotwoneft -87twofive -6one92six34vfive -nine82nine5dbmjmsixseven2 -6rmgq8eightqxrj3tkljktsjxz -onefour49sevenfour5 -sevenftckbsfivegfbgmpcvvvtqdhmbfive8 -hqrdprfhxpfjnlqvx2fivethree9onevxbqtpg6 -clz76eight -seven6fourjvxzrfivethree7cgtvmsfzb -4sixseven7jktrblrk7five -tqlgpnp682qnhpspbfm -mtfive4 -6ninexkds1slbdnlfp66nine -9sevencdqf -jcqccfzmgffrxjcvhpzonerlzkpvk71four38 -fourtwofourfivetjzpqmzvmmcseven3 -zqoneight9 -4twotwo -eightgfqzzcs8eightkkklhsvkmsseven -twosix4 -eightfkthjb83 -8gmqlpdbftwo15sevenjllkpnp -378onefourlqcq -rxlnmcphmzckgz9bpzonezcjcgvdteight -sevenfive2rmzbpmfvplxdvvldnghmfive -tvbctwo1twofoursevenkjbjd -veightbkkp9vntmeightjdrc -ltdmmnlsjzzxqtvnghxjnvg48bqvvvcj -seven4frssnmkjhf -nine975 -zcpdghhlhrvcmxftoneeight4 -rgkxgfkx6cqdxjhdqdf2eight2vzkbbpklqnine -one6six5 -six5seveneight -23krkcf -sdpthreetwo3 -eight28 -3twomdpsvbpvhthreegfrdfqtnttk -9sixsixcqbdd94bzxmjn -6fbbbrvzkzbhhlgthree -hgrnflhgqhd6628three -58tfxks -rfcmcfive51nine -3eight9 -6threecktkhlvcdkmcxdflsdrcfmkpxrmq -fourssvlkcsninesix38fourkfrgbdxlhx -mbhqsceightnine5bzxfnrzdgcvsg -gfjlsvmkfourhf9qfpxmlqkninecrbnjrfpninejdntmjglk -fiveonesix58onefourdnl -hkd33lgcjrpf6four -ftsbbgmv3fourrmctcsxrfv -rkmgfour58841 -gmgskgrfhc54cvpgkkhdhfseventhreefour -three9onegjdmsfthreelrpqfj1hdmbd5 -mkjbxcc9375 -onejxpczj2twofive5one7 -vhclzbp77 -8onesevenseven1 -3seventhfivefiveseven -bpnrkxlnxrq4dzjljgjg2five4three -fivekpxonegm76jqtjrlrns -pmmqkgdmljhdvsixsix6gdrrx -6rzjmrhlr -sixqnblcchkfnstwo9two4xdjns -twolmffnfmdfptjcdtwogqzhtbvph18six -5threefivefive2czfcvqrjcmlcctgninefour -9cvntxx -4sevengzlzjnntxz9ghcpcgvbm9three -2qcck3one -sixqxqnjxk6ls1rdtxkb31 -8onefiveeightljp2 -six7one85ptxktrlbtfdtz -ltgnfzcjblvrdclkonesqgbgplqm3threeeighttwo -1xmnr -pcxkjdtcmnineeight1rl8four5eightwoqvc -twovlhtdxctsnsixfourvsixsqfhbjzklsix2 -6hcdhsgzv -1six8qjdsfbnlzj93gpj -twoxfktts2xmjvcxkjjf -gkgqmdxcfkb6fjjzfsqbhnzxjzsvzkfv -6oneonefourxrnpf19 -qqgsckgrrh5svt2vsd6 -sixtns37 -jqgfcbrd7eightsixrgkqtkf -4bkfpntttsjonemhtcgsnzvjxcftzssdlntlv7 -9jvjqzgrzxslffdfhmcfournhqfckgmfnone -dgeightwothree2zhzfb2 -tldpeight77mh88two -49fiveeightfiveseven4 -three3rpbrvnp2rgnppsctpcqqfd -1one2sixfleightwokhz -7cnnnp6lzcjxfsqbbfqgvnqhklcktrvrlmfszmqchfnine -one9sdqnzhhnine5pkqthqsskrfourgkxbqpzkrxpkrvnk -gbhvg145twohnqfqnj2mxg9 -2sevenoneqfzbfqpcfour -pgcxrr3qhvngreight3four7 -vvbfrnqvgmq3eight3sevenllllfn -twonineqtklzqnd7fourjpqthree -82sixtwonez -nfmjv8pgqtqnkpmb83 -seventwontjbdcs8mthreeqdgfg1 -2fiveqeight -3ninexqt6fourfourone -9ninesevenzmhskrfour2qpqzhqpbgrfiveeight -twofxmpt7fvxkqbht -xmtgrngscqninesix5twotwo7 -onetwo8nvhckltwo -686one1seven -986l -4ninepxhzxmhgsixjncqfhqlnb -5tkvsnpp -njfqd5eighthgzsixnhxgt -seven3seven8seven -zceightsixninetwo9vxmfscp -threemgb77nineg1vzlbvhgrms -5onelfpdchkrqpshsixtwofiveseven -6zmjpkzxttksevenpkbdvksphjseven -smeightwo993 -one987cckfncdctz15sevenkdtrzkkmdz -8rhbpeightseventhree9 -nrnxccfzhrrxhsjhlthreethreenk1nine73 -nineone5threekxv2 -fivertwotwonnrlhqzfpbntdjhv5k -ppqtrhfkdbpkflpnlx85nddjxdctf4fx -lmtwone472 -3vcpbonejmtssvkn3one -8twoninembzfkjdtvdnd1three -eightsixzrrv35hmcpmgjkchfourrg -h87lhbgmzg48twoonenine -six1289src -5fiveqrmscnnqn21 -ninefourfiveninexlcpxt1 -onesix181onesixjds7 -4zvqzgvcd9dzhjzkcgflnhhfive -6threefive7dlvgpzh -3xtvthree -one3cjckmone1six -sixsdtgjtxhsh4qmkqgsp -bznsevenfive6seven6eight7 -7ninetwo4scmttkmkmhjgz1 -32fiveffxpvvfive -8twotwosglcjkxtfour -8ninetwo6fivetwo -ninevjfqnbqshgcnznb2two4 -1btbsqfgxz7 -37skthonehgnine -qprsldzcbzcskqpgpnvjt4fivegpqllvq52 -qnqpzpkmfj5ninejsix6bpcn2 -28jmvbtljsldltwo68fssrjvqtwonev -fourthreefivepxqrrjm7threezjsdhfs -7kmhsdlrsqlonegbr7 -onesixfourbdcgeight53lzpgjlsz -qgpgg377 -five17 -zpmslnjkqc3 -fourvmqhvhdgseven7jtpttjlzvsbfkdrj -bdgcfcsevenfive8527 -1ninesevennine -4sixfour4nh7sixnlkdk -shjz737 -7onecrhjhbqqnn2sixqqgseven -6six1kxpczbxoneone -512vnxncqgtsevenfivesnc -sevenrrdrzlht5 -6ltsix -87sixfourgjh -ngtzsrpxsfpmjzk2 -onefour462ql5mcfqrglrp -l88oneninetbh5nine2 -scgzzmeightqrltnkbjxrglbvsrpd2 -7krheightjlzzmthdrqsnkdqqlkone2 -three4fivexn2nine -sixseven8one6 -seven46five8 -bmbfd8 -one99xgk2 -fivetxfjpmnhdl7 -gktgcbronefiver2d -444six6 -dpdbxrtnnlsfkh694xnqhszfbvcc2 -53mznqnine4dpkkx82 -6sixldcgszrhhvrbhdnc -djfpppftbx6three9ncfour5two -eightljcvn565fivethreegsjbfsjsc -grdtdczfm5krxslvfk -1threekpnhkjbgch2 -four37 -ctlxgcgzj57gmninethree75three -lffrgk4 -one256jxbthjxhtj989kfqnrdhhxz -three3ddsxpt1lgkzlpxfiveninebsnbntpnnine -qxskrjjvtp1chgksksxksg79 -8zjvmfkpnrc32twotqdc6vshzv -8hgdrds54zk -twokr6vkbflkfrcjxvmninenineeight -grjxdtngmrthreerqjvmxbrdvlmqninegslrzfgmcpdhmg8 -5tkdszfcjdm -7jbzvrdprgdx7npn -ctwoneqcmffptjzpone3brdtb4bjnzqx -eight4tjfvrvlcfgdtk61fouroneightjvf -eightsix9four7 -827 -8pgcksninemrt -bggbhgh8 -fiveqsqvlsxc9jnhfdtqvsq71zvlh2 -3z1mrzxfdkqsixseven -kbrtclpktwo6btgpxnbrz8 -5ninefour6three -8ninefxfivekrkklfvnr6 -ftkndksixznvhxrdmj414seven -fourdjjxhb3 -four82 -277leightsixseven91 -4czktzmzctsdqgpqthreekjfm4 -78onezmcxjbrheightfourtltlrnjpg -zvclmdhrrbmslgfmrgtvzpnvqmth1one281 -dnkf3seventwo -sdtpcdc5 -rtn6vfmtvg -gkeightworqtjvmc3fqpzqsevenfivecxff -four49gxrkmfdl5three -9nine3326bcxnclqgsgbng -mjrvfrz7frq2sixfour -twosix3 -j7 -four73zfrdrns -st14pjnfgqpj -dlceightwo53dcjzxft9 -333mzmtlrhkjgsixcjzdrshhpv -vp6stsvtntboneseventwokmdvgthnine -92v2thc -seveneightfivetwofour6 -three76jfx3ninekndxqschpfive -fivefxgbhfour58n -nineninezgn6kbblgf -rjvrx4four71one51 -4mvmdqjfxhzpddseven7nine76 -86mbxjvs -3twosevenfiveh8fiveseven -54bczbfjq9cseven5 -nvghzbcjxn57nineldlklgb5fdkqvbzftl -97mtvstpkrzkrg46four -tp8 -four8sixphlcct5 -2pkccvfmp -ninevmvlmvqqnone69foureight9 -four2xlqrmlp48vdzsevenhtrcjbpc -ffvhhtgz78threeone -bfjnjxr342555 -4czvdggxlbzcthreerjfshqhmj7 -6three24khccsqcnddq -659 -five3lxchdtfvlnjn9mcs9jlsvzbcgvk -mfnonefivetwon2mrbsc -hvxv9three5 -75ninektwoseventhreefour -zvjrcxchzrz7seven -jhmbsknfm5498qtwo -scjnfvnld72gvtzd -8fivesixtwo -tdjkrtrdj7twoneg -8one3five -2nncbsevenseven -fourtfqfnsixfourtwo9threerblgths -twoninebgxnphjsixseven4 -threesevenxjgbpl321 -fourtwopjzfourqvnknmmdlsrhnkonefour1 -six9ninevkxnpmnpjrmnptwo -eightseven4fivethree8 -nine6nineonezdbrz621 -4fivezhvzlvrblm3mgzhf56 -dfkdbtreightfhrp1 -oneeightonecpnkkhpcpqt73 -nine9fdgbzxhvbslzlhkpone78five -two74 -5three36rl7vnk6one -onetj152twoqtjgvsnjpd -6ninefive -fourszvmjknhhvmznine73eightklhbbnrljk4 -89eightjcdftnine -gn7oneeightzcshvfttpnvxrxjdc -four78five44 -tnqmjzd2fivehqpkrkdrkqr -eight6eightfhbqqsqqs1twolhbfsjxfxj -4two4xhppfx -gnfqgghz4xnlcxqpccktwofivextpskbcnn7six -seven133bpthreeone5x -3five55four -6pgmbbbnmrrpdqzjkbsrpfhstwo -556vfzmcbxsqg8 -59fiveflckfmthdd3nine -2nine5six2twosevenqrdp -qsghpdqfivethreefive8 -ninesevennine1 -onevkqcgdc6 -bcdspxmhzsqfhhlghmqh5794blxm -8eight2twomd9gvtd7 -gfjxcczktc8 -ccpgbl3zqtmqjztwox -jvkvvklb5nine2dfsmkljl4hpjbhlpdmt -3rxzrnkdrnltzd -fivetwoone6 -zcsf5rnxgckhktworqsqngvk8xdgtfcdseven9 -rsbfcsix3jbqnqeightsixonelrhfhlldhhfg -njpnzndmdfzkpdseven5rvcsxheightthree -ninethree6zplfz1seven -7dknfz -ninebkhfqdsrone2two5six4 -1x -mhrzpkcmf5three -9vzrqrmtzqnkdhrhv -g3 -sixthreefourtwonln9fourvqgbbht -vfvzttx86db -cpcrxvp5eightfourseven5fivetqnine -7fsfmgbntxrmjmpmmkcnbx -sevenrkmm6threeseven -fivefivebgdssdxqfnthreethreelvln5eight -vxrxtzmtmtssjsevenfourmnhtzdthree4fivesrpcrb -t8fxpzbnfivesix6fhrcklhvfive -6threetzjvzkbdp -gflz6nine5 -ldnn7qjz1lcgsmvjpbtplztmvseven3 -threefourtwoeightdfpbjbggx3m -4nineonenine6kkzsmfdrl -lmmpsdmnnsrgkbzcdfive5 -4onethreejcrgddkxthree -9twonexr -pvjdlxv1xlgkdsixsixone1four -fourtwofivenine2 -xl8 -tfmfive7 -9q8svkhxgvbmhseven -fournmtqnnphzckqsnpqddlvgff1ninetfhdknbnl -6fivetwo59gxbzxrkdvhfive3 -ndbrshkmc9 -4fourseven -lkdcxdkkxthq5 -ftwo2pgpljh11fpbgl2 -hhjrfcchcjlhninexmv6 -9bpzdrrfqcs7eightwob -8eightfive -57nnbqt5eightzvfblxstz9scfnnv -92three7xkkdskhvseven -ghlbrzxhlkh63three -5nine7fourtwo78 -3dvxdphhxgrbfrlq4qxzslfng8rrfjnpjdnxc -brq68eightoneightvrx -four7twooneeighttwo -onenine2nineninesixfive -slltwone8kngkhvgkkphrmgprnm9 -twonhsxggcslm3zqmsixfive -pzgpspbfivetwosix9btjbdfbdeightj -fivezpdk34ninephlzvddrmzvkztwo -sevenfour223qvxrdrvqgkqpctbrzeightqtxjnhgz -7373sevenrrsfzsfour -rttwovggcqtzx2993 -twonineonegpcpdqrpd284 -2fourfrzkbkhninegseven83one -1pjqvdntbseventhree -eight19tszhr -hngn5fqfcfxrnfs -6xsxcgkdstncdl19c1two -cvrdkrqrmssevenfivecjblqxjbzqtvkqhmcm18 -zqtblgtqttwo9gmkcfkdcgbq83 -bdrmrsrdfponeeight3fvvsrfbshbzbqztmhbbzpkxxnb9eight -4trjldtsjdc8vkgvseven -37fourfive9three7nine -fourseveneighteight7fiveonexxmmjzlbhk -fivetwothree8seveneighttwo5nine -mqmeightwo3 -8cjkdcdk -6cjnjht51knzzcsqkvtwo -5dshlzzxxggninesix1two -9seven1eightonef7 -two75sixfivesixhthreethree -1fntfzqrjcxlfprglcsix7 -4lgcgkseven -r15two -eightdsxsnqgfnbntvnqtsfpr1 -sddbms6nine6 -7tpdrfpbd -flmztqone7sixzdqlxhfiveoneone -jzpvdcvnzmmgzhxlcsevennine2 -nineseven3cqktfscgtf -rdhrxhfn8hbhctkkxz3 -7cjzxmlvq48kvmxgmcd -twoeightlqpfv5fourdfv77 -8sixfivegnsevenlgdkfcfznine -fk8hcndpfflmsbjlseven -1onesscdrlztwoonezfm -n8xdcmfxvvgm1b -psix3 -gmpnine5ninekfmmhbrnq -713six -gqplptccrthreethree3jdgbtx -1onergncpbv -5fivetwo7two6nine -4sixqrrtqjnv7 -onetwo7364fqrjghsbzp -five7shstn -5sixkcspphnsxndzfdghh -jhxpxxpfz4sfkpgeight9ninedclxgv3 -fourqfzqsgpt4ljtrrxn2 -8seveneight6fhnf9onethree -bjgdq8two8m6bnnbdtqvlf -eightgjrvdjhz6 -rdkvkqhfourdpn7tkjbflm7 -1ptthreeeightonetwogbh95 -92four96 -2sevenpkfgj75 -lpfnmmp2eightmbrzxdskx7ninetwo -gjmxfive7qqrbsr -qxprvlrhxlj1threethreevrvvc2eighttwo -vdqmnccqsplkpmspqcggvllsxvh1 -fvdhvmgzseven2fnrrslbdtwo6 -fivefive9smbxkkp192 -vbsdstvbknldcgkzkgqjln7 -mklnltnfsixphfgfzseven8fivenine -jbshrqn2three844 -6nspp1one7three5 -six3four571 -nqjssphmsbhbfhp822one -9kffmtffiveeight3 -sbfbphdgjh4sixbfcrzmnlhxcsksctb5tdtm -7bfzk7mvrglxjfour2tzrkz4 -onethree36 -zdtcr45four2tpgqsix -sevenmqgjhcjpnine63zllrtnm1 -jnccdbplkfq6oneightd -one8flhbdbl93 -rrmd34 -six1lkthggkbtwo5onesixthree -eightl294eightlb -eightzngvqdmfgvfvhlrxnfourcfggfgp9 -dkmzgc73l -839fourone5 -xfklsdj6three22 -soneight6cvgndhbtttlbpqktwo -5nine1four471pnnvsix -zqrfmnpgzkqrshrpktfbndvfmrcjhfqlhcbn9rrffzngrhnthreedbgcm -xcmt2fournine -seventfgnkd87sixthree -77fktkx -3mdzzsvdmltl7jeightfivenine -seven988five -9975 -eight4sbc5eight9 -mxj53bsh8fourzv4 -817 -99ninevnonecfcbsjgnrzrdffll -twofftvkshm4 -one221jjbtlgdtt -68sevenfive2lhrblxpkdq8nine3 -39cjrgljlvxdfivenhptwoccjbhtnmqreighteight -sixfoursix74fzdtnx92 -rhpktnqsvqxn51 -35nine1 -43gqzppsnktxm2 -5five566dtbppfp -nine7one23sixsix -93fourbqmsspdhr -cm5qcfxfcsg3qcvstwozhsnspg -227two -qfrtvpnh8 -one4jzmmmjjk -4vxvngmtjxldcn2 -bjgb2kvrlshdvfj1hnpfbtxkp -7eightpzmxcmcnsmtkxjt -hzhjbddqj961zkxgmhxdthreetwo3 -7fivetwo5dvpplrmxqrzxtwofive -717mfszgrbt -chqhsqt7hcmbjqstfive -threesevenkknvhhtt7399k -7n -6twohzlngv -eightthreekkgt9mqzvkql9txh4 -8fcsndmltseven -twodjscb5sxfourtwod -5ssbz -onedvpnnfvqxvfour1jggdsxfdgrqfrgvssix -sevenk94mthklgmsxhxdjxslvfive -bjqshcpk26 -nine7sixzx7 -9threexsfqxqhvvbsjzrbmxcfssix -geightwonineqp7twoeight79 -8b8dllrmvgnmhshvkhm -7grpghbfourlsixthree7 -1xzrhgxsh7threetrqqvsl1hcmmk -fivetwoppnseven9sltkmcsntzldvqzfour -6flgcsj -nine44onedninesix7 -hrlfdsmjqtbpfpxljhjrrxrrdnrlzf34eight -sevenrzgsvq6 -39sixjshdjrfmstwo2tzmzhgggdqgflp -tcrvlffrmqrcx6bqbvhlcbgtwo351 -9281qzt35jmtpjgqq -qpdtvpmfbqrmthreetvlsr2fzbzkthreerhqvqbcnj -two3fgrnggpcl -7onexrnvssfjczlmkzgprnone2khmhntg -6lzggxthreefour26tnxfcqbl37 -8rgnffphzgponejfive -bmpsevennhrkphhbfz8nine -5mkbbjdcqninenine9 -zrfvhcreightone9five -19chrfkm6gqlfcfhmslmcmr -dzrt197twonine -vmrlbm5five -pthree3six417frljvddzjtgdvmmh -fournine7lmzdrxvjsixlmfsgtwonesn -ngt8fdcsgmbbvrone3 -3hfhppzdfp -sevenqvrlkpgxnqfivexnzpxcnine99 -38oneightg -4fivezjzsstlfxp1pdjmmnvjvtthree -xfngrdrfseven5rcsqtflhsqz -three3jtndtxpx -eightfour8xxtkjsjlrsmg6 -1qnjttkhzltvj2xtlts6lqlxrf -eight817two52sixgmhsrnlzm -fourgxbk81 -eight6eight -4pllfiveeightsixonekhxvhvx1 -41twothree -9pcdldnine -vkkncnrblg2x36 -sevenzrqsix3 -ccpnk5threeeight1 -rj69 -ninedzgnsvrjbg4eight -nine3onesevenxvpmmt5eight -drcbrg9eighttvdqgrchlqnineseven -five6two3bgzgtvxmj8 -sixfive9 -7txddsmg2hzhz1fourkkthree1 -3pvgxxxmpt5eighttwocnvnine -cdnbkl3 -twosix9sixninevftwo1 -392 -427twozqp79sixtwo -2jpkrm16 -threelbspfkeighthxmmcpprmeightthree3 -bvtfzpr36nine -qdzfdzbvnk47twofive4two5 -ninethreedfzrphlvkpbvtvmzjxgmrh6five -cjnq7gnpnpt -six8nine2 -chsdgnlrzqnddfjthreebhfdvlgfpfshkeightseven6 -nmlqvslhk6fourninexpzlf9pfnbrnhphxzxh -eight9nfgtsjxnteight8pfpfctjxxbffxsmjtwonegcd -nine8m1 -9sixseven -218 -6brzzmkxsm -ftxrrhzz1five98kninepc -3kkmbvvvtwoksspmqksevenoneplone -eight3sevenfour7two8md4 -jvtk22472 -threetmpkcsjsixfour6twoseven4 -kclmjgdplc23ninekmqbrkxrkdhsnnhmthreecfive -xkzbzkszml641one54phdfghtbdd -3442four8vr7 -6lthree -lfrlxpczfiveseven2 -fhjjlb1fiveninempnvlzbkhsvqf6 -fiveone66onesix6dtwo -91bgqfz1four8 -7two8sevencvfjhqmdtfone -889two3db36 -sevenhlljx5qoneeightfivemvsmbzdbznine -one45sixft6eight6rbf -gdsevenknlfourkmzlpvv3flsfvnmfseveneight -3qbs622fivemzqpxdfkssix -275fr2eightoneone -lktbgbhngfbrzdponerqstslfourhjxgmv1qcj -two9fivelsxpd2six -9eightnine -qmteightwosixseventznkgmnhjvdfxvqv8 -ninenine9jdgndgnfour3pgb4gdpjnt -three3sevenzcbllclmseven1threeeight -xzbkxnttninexsj2 -ngrgdonefive94fivehgnt7 -3nineqnvhsninetfeight22eightwoqf -phrzskrhbd9five8nine -dqqnfive1 -hsjrhjvmlqxltxxgqx6qbfsnrhgbkl -four5hrpnq -vfsqhhgb6eightgtjlvnxnqsrjn3pg -71fiveknrgx7 -dpeightdbvpnfour1 -two59blldsls85 -three22nfvmtd77mbjnvxqbdxkxvp -five56five22 -jtqeighttnkzkbbtwoninepzxphtlbzsv8 -1zhktrqsklfivegxdhrqt -three422 -8sqlrqn9 -zh8 -1fourone8 -94kkqb9four9 -6sixkbvxf -rbvxqgztwopcbhhgzthl6xsix1qjrvfive -two29one594brhbpnine -7fivebczzcfeightfour -bxqrdcx7sixthree -xjqchs31twoeightthreesevennine -83five8qvnrcllfhddhltsevenone -gsjjxtvtck7six -cxsbtkzcgjbgninehhmzzfnine3bpzg7 -six7threedbhtvcvjtmeightz -pdfmjbqgvkr5t -cqbkrkfivexkmvgqfbfsg5zmfhbqkdcq1 -6ptrseven65tvbjkqlhjhjq26oneighthsp -39eighttwoninetwomnszqrmtvj -hfpcgzrp8pmmvonevtnfpfltmgxqzntwo -seven6cd8eightr -1vbpfiveseven5gsqdpchrjzfour -7zlxvvjmlnonesix67two2sfggmgbmm -rmgvfvdhhgztrrn966six9oneone -6nkvznctwoone -eightthreeg9nine7six -shthreethree1 -tm1eight8rone575 -nv6 -tpkgndlhdzlfour1fouronethreenhmgtjzn3 -9onetwol2qmltninehtrmfxcsbfghk -2vbqxkgp5two89one -428ninefcskeight -g3fournine55eight -hmnvcgtqsixfivebone6 -mpcp55xdfive33mdbsc -bfpfrrlqsixfq9cnzvffncbn -hmpvxz3fiveklnnjcvgxtplhhzdrn8seven -gqr6fiveltkqqfvkhconeseven4rlqnvmmkgcx -two2eightwokcr -eight1zmqpcjbbxkkcnk8 -pq6qhfnm -sevenseventwo5three7 -7eight1mkpmsvpmqfjnvqzgbjkmpc2 -gtwoflpblvv6xzpblmfcbx -32five -four3two843nlxxhktmcdoneightjh -89gjs7eightnineonethree4 -4rfcbkgrcfb6three7jblgcrrxp5 -mhs47tqvkt31twofive -pspptsbp55 -fourfour5twogdvjvskqx8foursix -eightxfvnrpcvjtfkvlng91eightcdgzhxzcm -nine5psngtrxms5vnrbjjrpgt -5xnlqscssbfiveeighteight14 -svzlbtdkhs5eightfourgzhsix944 -fourbphkpbkcfss5l -4four6 -onetwo99 -nzhlddbkgcbxvpfour1twofiveseventhree3 -2one2txrzz8fivethree -seven86 -two3tznttbfkzzbthreexqhxqmbj -dskppdthree2 -seven4lfive -hnftvrk8fhhzrqzxxqzbhvjhflv2nine -eightsix2zbsgtdvrone -rmssljck3sixfivehvsvtwo9ctrbfvhpxfrr -3nphszlp7ktrtzflbvxnfive -cfrrckdlfmjkmvjbtxnsdq613hxlsix6 -spljfjrlrsix2fsl -threeonezdbmxps9 -two2lnbvmmpnqq8ssonethree -vvpjpvm6two7 -424 -threek811nine1five2 -82mfsgmh -ninerrjtnkm4nine -sevenonenine7 -nine16698llgxbbglggone -knhnxtj6ntkxnine2eight7 -286nx -twocbxfonenineonerxvdjzjzcp2 -2one5 -ninethree25sevenfour69 -chthreeone9eightoneshlgndnrjoneightcs -2onenvfszxbphone -9threefour -eightonenine28one -3bshksixrlncdqtk3foureighthjcmmktsvx -prlsj7seven -gqxoneightzmcsqsbvhbthreefive16 -3kbqbzm2sixnine52onekrtoneighttq -hqnfive2one -jfive17onemzd -6one2eighttnjzjk -vtmcxnttlxltcmseven2svp2pnzkbgzzzj2one -54mhqbcpzgsd2ld -3fvbnineeight -fivejrxqnqp11cxeighttwojqbqnhmeight -twoonetwo49sixxjbkdoneseven -7qnqpfb9xrhtxkfz9three -one8four1 -2r3lrgjltxxlrhrvfltwoonevq -jkptfcvdtwo347mjrqd -eight9cxstff -7nqqbkcsftknhqffjvr2sevenpkjvtc -seven5sevenrsthreefiveone -8mmvdqhone584eighteightfive -7sevenjjgvr4 -465nineninesqnslzrfpl -ljqnr737gvfmpjztrsbns8two -hkmdgbbrzpjczpqkhzkdmndlftxgtwoeight26 -nhskzhxfk26lpklkkkdnxeight -sixrqcjqseven7sbqlnpqvshxninebxmkxfrznine -xlrrfnt7jjhfqzr -one9six3 -sevensevenpsbgtgqpmbsbbpldvbz2qsstxlcgkd -5qpmvbnpfiveoneeightsevenone78 -four69seven -2nv -1twovfmvk33gcrsfgdbms -fivetwoone93 -g4sixjbcqttbhnp6fourfplmzdtnltnjqdsthree -f3 -one3ninefiveone3hlsthrp7 -lmdgzgkrq747nine -fourtwo7 -7353bdninesixxtc -njnsprmjxcjn42sixp1 -92onefour -5eighthkdf -263fiveeight -four96one52fivendcnqcl -rcntpkdtjlcxkdg8 -nt7g55ninetfzrjmhrv33 -two19 -ninefive5threetwo73pxjfive -onethree42 -9dctnplfgkeight9 -xpjtknfive6five -q1ninefour7 -twohfdckgcddpmjbpmgbxnineeightxcxkhssjt1 -8hgcs3onemnrcfbgsh9fdc -7zmgns94ninenmm -3four3 -hrrt3nine292fourfour -ljsbmrfmnpgg799twosixfoursix -sixjj6 -gqmvmmjsjrgn7fiveninetwovnjbs -m2 -525onefive -ninesixlm7fiveeight -fourfour6eight5gpkpjdxqvrsp -two5sixkrmxnszf1eight6seven -1bbmmf -26two -9eighteightfivesix7 -mcjcdnhlxv92qfbfbdpxfnxgbqsnxkonethreeseven7 -9qlvlrfivefzdxpmttsllhntpxpfthree -djdjgxdpnd82five -fiveonenine19four4two -five69two7sfj -twoonelvmdbdq2two -qxeight6trprdmgqzj4 -eightfourdvmbvnjthreetwormzfr4qgdctg -fournngpdffcxt1six -seveneight6zeight9 -fkkmfbd7nineseven -twobtkvbzgplfpjfiveseven5 -9jsjkjhgtghbqltldlcpqtvgpmhsixsix1four2 -kxcgkvkmnblfive438 -six6lbbqlttnvfiverxceightwobx -8sevenseven6three9ptfggzkhm -one7ninemdjznbqhfkckpjkxtwo12 -1bvjgdjlll -43kjdtwofiveseventhree9 -fourlgzcrldtwoseven9xndlqvbrtonennvlvzplrt -8twohzmcknlmqd -gshhvf5twodqgdseven8fourfoursix -nineone47sixeightrp -4stonekdgdhxrtqv9sixonevhhmhqzp -8lmpppc -4five8ffive -fivefivesmmkh6jhtggr4 -tjrr9ninenine -six6fiverqdlm67hztn2five -six3278xsddmnz -8qlhdpxn645nhrjm -xlfttcfs6jgtbeight6sixdvpl22 -87tcj6gkjfrrmdjbgh4 -6eightsevennmdpkkmkqrffgshrfhml7two1 -ninemglsrmvqrk5six -9nfgt1rntwo1826 -three2fiveonexrllxsvfive -9zjfkmdfbfqqf2mxpnqsmsthjzzszdxl -43eightnvdrthree1eightoneggrdmnp -pffldcmnlpsevensixqxhdncrclbc51five -5bqnlphone6 -195one diff --git a/2023/day1/solve.py b/2023/day1/solve.py deleted file mode 100644 index b6a47c1..0000000 --- a/2023/day1/solve.py +++ /dev/null @@ -1,24 +0,0 @@ -def main(): - final_value = 0 - - with open("input", "r") as f: - for line in f: - line_strip = line.strip() - calibration_value = "" - for char in line_strip: - if char.isdigit(): - calibration_value += char - break - - for char in reversed(line_strip): - if char.isdigit(): - calibration_value += char - break - - final_value += int(calibration_value) - - print(final_value) - - -if __name__ == '__main__': - main() diff --git a/2023/day1/solve2.py b/2023/day1/solve2.py deleted file mode 100644 index e545cf3..0000000 --- a/2023/day1/solve2.py +++ /dev/null @@ -1,65 +0,0 @@ -def main(): - final_value = 0 - text_digits = { - "one": "1", - "two": "2", - "three": "3", - "four": "4", - "five": "5", - "six": "6", - "seven": "7", - "eight": "8", - "nine": "9" - } - - with open("input", "r") as f: - for line in f: - line_strip = line.strip() - calibration_value = "" - - text_digit_pos_first = -1 - text_digit_value_first = None - for elem in text_digits.keys(): - pos = line_strip.find(elem) - if pos >= 0: - if text_digit_pos_first == -1 or pos < text_digit_pos_first: - text_digit_pos_first = pos - text_digit_value_first = text_digits[elem] - - text_digit_pos_last = -1 - text_digit_value_last = None - for elem in text_digits.keys(): - pos = line_strip.rfind(elem) - if pos >= 0: - if pos > text_digit_pos_last: - text_digit_pos_last = pos - text_digit_value_last = text_digits[elem] - - for index, char in enumerate(line_strip): - if text_digit_pos_first != -1 and index >= text_digit_pos_first: - calibration_value += text_digit_value_first - break - - if char.isdigit(): - calibration_value += char - break - - index = len(line_strip) - for char in reversed(line_strip): - index -= 1 - - if text_digit_pos_last != -1 and index <= text_digit_pos_last: - calibration_value += text_digit_value_last - break - - if char.isdigit(): - calibration_value += char - break - - final_value += int(calibration_value) - - print(final_value) - - -if __name__ == '__main__': - main() diff --git a/2023/day2/input b/2023/day2/input deleted file mode 100644 index df90739..0000000 --- a/2023/day2/input +++ /dev/null @@ -1,100 +0,0 @@ -Game 1: 7 blue, 5 red; 10 red, 7 blue; 5 blue, 4 green, 15 red; 4 green, 6 red, 7 blue; 5 green, 8 blue, 4 red; 5 red, 4 blue, 3 green -Game 2: 8 green, 3 red; 7 blue, 6 red, 8 green; 7 blue, 3 green, 6 red; 8 green, 6 blue, 11 red; 6 blue, 3 green, 12 red -Game 3: 6 blue, 3 red, 7 green; 3 red, 3 green, 8 blue; 8 blue, 11 red, 4 green; 5 blue, 7 red, 6 green; 9 blue, 7 green, 1 red -Game 4: 3 red, 4 green; 5 red, 1 blue; 2 green; 3 green, 1 blue; 2 green, 1 blue, 1 red -Game 5: 17 red, 5 blue, 3 green; 8 green, 9 red, 10 blue; 2 green, 9 blue, 4 red -Game 6: 5 blue, 6 green, 3 red; 1 green, 8 blue, 12 red; 2 blue, 13 red, 6 green -Game 7: 1 green, 1 blue, 6 red; 1 red, 8 green; 3 red, 8 green, 2 blue; 14 green, 4 blue, 4 red; 4 green, 5 blue; 7 green, 2 blue, 1 red -Game 8: 6 blue, 9 red, 3 green; 2 red, 6 blue; 2 green, 1 red, 2 blue; 2 green, 9 blue, 6 red -Game 9: 5 green, 8 blue, 8 red; 2 blue, 6 green, 8 red; 6 red, 9 green -Game 10: 2 red, 2 blue, 12 green; 8 green, 3 red; 5 blue, 11 red, 6 green; 14 red, 1 green -Game 11: 2 green, 1 red, 1 blue; 4 blue, 7 red; 7 red, 7 green, 5 blue; 2 blue, 3 red, 6 green; 3 blue, 9 red, 7 green -Game 12: 9 green, 7 red, 7 blue; 6 green, 4 blue, 1 red; 3 blue, 5 red, 7 green; 9 green, 10 red, 12 blue; 11 green, 5 red; 9 blue, 12 green, 3 red -Game 13: 7 blue, 7 red, 2 green; 5 blue, 5 green, 7 red; 1 blue, 10 red; 11 red, 2 blue, 1 green; 1 green, 1 blue, 4 red -Game 14: 2 blue, 10 red; 3 blue, 6 green, 17 red; 3 green, 4 blue, 14 red -Game 15: 7 blue, 2 green, 4 red; 7 blue, 3 red, 3 green; 4 red, 2 green, 1 blue; 2 red, 9 green, 5 blue; 2 red, 4 green, 5 blue -Game 16: 5 blue, 1 red; 8 blue, 1 green; 5 green, 3 blue, 2 red; 8 blue, 2 green; 2 red, 2 blue, 5 green -Game 17: 2 blue, 5 red; 7 red, 1 blue; 2 blue, 2 green, 3 red; 3 blue, 2 red, 1 green; 5 green, 7 red; 6 red, 3 green -Game 18: 4 blue, 1 red, 14 green; 8 red, 4 blue, 14 green; 6 red, 11 blue, 10 green; 5 blue, 2 green, 3 red; 16 green, 10 blue, 2 red; 6 red, 4 blue, 12 green -Game 19: 10 green, 12 red, 12 blue; 5 blue, 12 red, 7 green; 15 red, 8 blue, 6 green; 13 green, 1 red, 10 blue; 4 blue, 8 red, 9 green; 16 red, 7 green, 3 blue -Game 20: 10 blue, 9 green; 9 blue, 1 red, 3 green; 11 blue; 6 blue; 8 blue, 10 green -Game 21: 4 blue, 4 red; 1 green, 3 red, 3 blue; 4 blue, 1 green, 2 red -Game 22: 5 blue, 4 green, 1 red; 14 green, 4 blue, 1 red; 4 blue, 4 red, 13 green -Game 23: 6 red, 8 green; 4 green, 1 blue, 7 red; 10 green, 5 red; 2 red, 9 green -Game 24: 1 blue, 10 green; 12 green, 5 blue; 1 red, 3 green; 2 red, 4 blue -Game 25: 2 blue, 3 red, 13 green; 7 blue, 15 green, 1 red; 7 blue, 2 green -Game 26: 20 red, 5 blue, 4 green; 1 green, 8 blue, 11 red; 7 blue, 6 red, 2 green; 4 green, 7 blue, 4 red; 5 red, 8 blue -Game 27: 3 red, 3 green, 1 blue; 3 red, 1 blue, 8 green; 3 blue, 4 red -Game 28: 1 blue, 15 red, 2 green; 15 red; 3 red, 2 green; 3 red, 1 green -Game 29: 4 blue, 7 green, 1 red; 5 green, 9 red; 8 green, 1 red, 10 blue; 2 blue, 1 green -Game 30: 9 blue, 5 red, 6 green; 15 red, 6 blue, 3 green; 13 red, 2 blue, 4 green; 2 green, 3 blue; 13 red, 8 blue; 5 green, 6 blue, 17 red -Game 31: 1 green, 9 blue, 9 red; 4 green, 8 red, 1 blue; 10 blue, 2 green; 1 red, 1 blue; 1 red, 1 blue; 6 blue, 9 red, 5 green -Game 32: 7 red, 7 green, 3 blue; 14 green, 11 red, 11 blue; 10 green, 7 red, 2 blue; 1 green, 4 blue, 4 red; 9 blue, 10 green, 5 red -Game 33: 12 red, 4 green, 11 blue; 4 blue, 10 red, 1 green; 7 green, 10 red, 16 blue; 15 red, 5 blue; 10 green, 4 red; 8 green, 5 blue, 6 red -Game 34: 8 blue, 1 red, 2 green; 3 green, 3 blue, 4 red; 6 red, 3 green; 6 red; 9 blue, 4 red, 3 green -Game 35: 6 green, 6 blue, 1 red; 3 green, 3 blue; 1 red, 5 blue, 2 green; 1 red, 13 green, 1 blue; 3 green, 1 red, 10 blue; 5 green, 4 blue -Game 36: 15 blue, 1 red; 2 red, 3 green, 17 blue; 6 blue, 7 red, 8 green; 12 red, 7 green, 14 blue; 4 blue, 2 red; 8 green, 12 blue, 10 red -Game 37: 2 green, 2 blue; 6 red, 3 blue, 1 green; 2 green, 3 blue, 1 red -Game 38: 2 blue, 7 red, 9 green; 3 red, 18 green, 6 blue; 6 red, 19 green, 2 blue; 2 blue, 13 green, 7 red -Game 39: 12 blue, 7 green, 3 red; 16 green, 6 blue; 1 red, 4 green, 2 blue; 15 blue, 2 red, 2 green -Game 40: 18 blue, 1 red; 4 green, 15 blue; 5 green, 17 blue, 3 red; 4 red, 16 blue, 2 green -Game 41: 3 blue, 14 green; 11 green, 8 blue; 14 blue, 4 red, 1 green; 5 blue, 2 red, 15 green -Game 42: 7 red, 9 green; 10 red, 19 green, 10 blue; 16 blue, 8 green, 7 red; 6 blue, 11 green, 7 red -Game 43: 1 blue, 5 red; 8 red, 2 green, 1 blue; 4 red, 3 green; 2 green, 1 red -Game 44: 5 green, 13 blue, 12 red; 18 blue, 3 green, 8 red; 2 green, 3 blue, 11 red -Game 45: 3 blue, 1 red, 4 green; 2 blue, 1 red; 1 blue, 4 green; 3 red, 16 green -Game 46: 10 red, 1 green, 4 blue; 4 green, 14 blue, 2 red; 12 red, 3 blue, 2 green; 4 green, 2 red, 2 blue; 2 red, 1 green, 11 blue; 2 green, 19 blue -Game 47: 10 blue, 10 green, 3 red; 3 red, 11 blue, 9 green; 4 blue, 10 green -Game 48: 5 green, 1 blue; 4 red, 8 green, 8 blue; 17 red, 5 blue, 2 green; 12 green, 18 red, 7 blue; 15 green, 14 red, 8 blue; 11 green, 1 blue, 16 red -Game 49: 2 red, 4 green, 1 blue; 1 green, 5 blue, 2 red; 8 green, 3 blue, 1 red; 4 blue, 3 red, 9 green -Game 50: 2 blue; 7 green, 5 red; 3 red, 3 blue; 5 green, 1 blue, 2 red; 5 blue, 3 green; 4 green, 3 blue, 1 red -Game 51: 6 green, 13 blue, 3 red; 7 blue, 7 green, 1 red; 15 green, 2 red, 13 blue; 1 red, 7 blue, 3 green; 11 blue, 16 green, 1 red -Game 52: 5 blue, 2 green, 14 red; 4 blue, 3 red; 10 green, 7 red; 1 blue, 10 green, 10 red; 9 blue, 5 green, 12 red -Game 53: 1 green, 2 red, 1 blue; 4 green; 1 green; 2 green; 2 green, 1 red -Game 54: 3 green, 11 blue; 12 blue; 1 red, 3 blue; 7 blue, 1 red -Game 55: 7 green, 7 red; 1 blue, 7 green, 14 red; 17 red, 2 blue, 5 green; 1 blue, 7 red; 2 blue, 3 green, 14 red -Game 56: 3 blue, 2 red, 1 green; 1 red, 4 blue, 2 green; 5 green, 1 red, 2 blue; 7 blue -Game 57: 1 blue, 14 red, 7 green; 2 red, 1 green; 1 blue, 6 red, 6 green -Game 58: 11 red, 2 green; 3 green, 8 red, 8 blue; 10 red, 1 green, 13 blue -Game 59: 11 green, 5 blue, 11 red; 13 red, 6 blue, 11 green; 6 red, 7 blue, 12 green; 9 blue, 9 red, 1 green -Game 60: 3 red, 8 blue, 4 green; 5 blue, 2 red, 3 green; 7 green, 3 red; 8 blue, 2 red, 7 green -Game 61: 17 red, 12 blue, 9 green; 20 green, 5 red, 14 blue; 9 blue, 11 green, 15 red; 14 green, 6 blue, 14 red; 16 green, 7 red, 4 blue -Game 62: 3 red, 11 blue, 16 green; 1 green, 6 red, 6 blue; 7 green, 6 red, 9 blue -Game 63: 3 blue, 20 red, 1 green; 11 red, 5 green; 13 red, 2 green; 15 red, 1 blue, 6 green -Game 64: 8 blue, 1 red, 11 green; 1 red, 11 blue, 4 green; 5 red, 7 green, 1 blue -Game 65: 3 blue, 13 green, 2 red; 2 blue, 3 red; 10 green, 8 blue, 2 red; 2 red, 6 blue, 8 green; 10 blue, 12 green -Game 66: 4 blue, 3 red, 8 green; 1 red, 9 green; 7 blue, 6 red, 6 green; 1 blue, 1 red, 11 green -Game 67: 10 blue, 15 green; 3 red, 2 blue, 1 green; 4 blue, 12 green, 2 red; 8 green, 11 blue, 8 red; 9 blue, 5 green, 6 red; 10 green, 4 red, 14 blue -Game 68: 4 green, 3 blue, 4 red; 9 green, 2 blue; 6 blue, 6 red, 10 green; 5 blue, 4 green, 5 red; 3 blue, 10 green; 5 blue, 5 red -Game 69: 6 blue, 1 red, 1 green; 4 red, 3 green, 2 blue; 5 green, 3 red, 5 blue; 5 red, 5 blue -Game 70: 2 green, 1 red; 12 green, 1 red, 11 blue; 7 green, 12 blue; 13 blue, 10 green -Game 71: 9 red, 9 green, 4 blue; 10 red, 1 blue, 12 green; 3 blue, 13 red, 3 green -Game 72: 2 red, 8 blue, 5 green; 2 green; 1 red, 5 green, 6 blue; 1 blue, 3 red, 12 green; 5 green, 14 blue, 1 red; 8 blue, 13 green -Game 73: 19 blue, 11 red, 8 green; 18 blue, 9 red, 11 green; 6 green, 19 blue, 6 red -Game 74: 2 green, 4 red, 2 blue; 1 green, 1 red, 4 blue; 2 red, 4 green, 2 blue; 3 red, 2 blue, 6 green -Game 75: 2 blue; 1 red, 1 blue, 1 green; 1 blue; 5 blue, 2 green; 1 green, 1 red, 3 blue -Game 76: 9 blue, 4 red, 3 green; 8 blue, 8 green, 3 red; 3 red, 2 green, 8 blue; 8 green, 6 blue, 5 red -Game 77: 7 blue, 17 green; 1 blue, 2 red, 18 green; 18 green, 1 blue, 2 red -Game 78: 2 red, 2 green, 1 blue; 5 green, 3 blue; 1 green, 2 blue; 2 blue, 6 red, 5 green -Game 79: 4 red, 6 green, 17 blue; 2 blue, 3 red, 8 green; 8 red, 19 blue, 12 green; 5 red, 8 green, 12 blue; 16 blue, 1 red, 12 green; 5 green, 18 blue, 8 red -Game 80: 1 blue, 4 red, 10 green; 6 green; 6 red, 3 green, 2 blue -Game 81: 2 green, 5 blue, 4 red; 3 red, 1 green, 14 blue; 3 red, 10 blue, 2 green -Game 82: 12 red, 5 blue, 2 green; 12 blue, 6 red, 5 green; 13 blue, 1 green, 3 red; 11 red, 3 blue; 4 red, 3 green -Game 83: 10 blue, 16 red, 4 green; 6 red, 2 blue, 14 green; 9 blue, 14 green; 7 blue, 1 red; 4 green, 2 red, 8 blue; 5 red, 7 green -Game 84: 3 red, 3 blue, 6 green; 9 red, 17 green, 16 blue; 13 blue, 7 red; 14 green, 2 red, 14 blue -Game 85: 7 blue; 8 red, 10 blue, 1 green; 6 blue, 9 red -Game 86: 9 red, 6 green, 9 blue; 1 blue, 5 red; 11 red, 1 green, 11 blue; 3 green, 8 blue; 8 red, 5 green, 4 blue; 15 blue, 4 green, 2 red -Game 87: 2 red, 2 green; 5 red, 2 blue; 6 red -Game 88: 2 green, 5 red; 9 blue, 7 red, 3 green; 1 blue, 2 green, 3 red; 3 green, 6 blue, 1 red; 1 red, 3 green, 6 blue -Game 89: 10 blue, 13 red; 15 red, 6 blue, 2 green; 2 green, 10 red, 18 blue; 1 green, 18 red, 8 blue -Game 90: 2 red, 2 blue, 9 green; 1 red, 9 green; 7 green, 3 blue, 2 red; 4 blue, 2 red, 4 green -Game 91: 6 green, 4 red, 9 blue; 4 green, 4 red, 17 blue; 6 blue, 2 red, 4 green; 7 green, 2 red, 13 blue; 1 green, 13 blue, 1 red -Game 92: 4 green, 1 blue, 8 red; 7 green, 6 red; 13 red; 9 green; 6 red, 1 blue, 4 green; 2 red, 1 blue, 15 green -Game 93: 8 green, 8 red, 13 blue; 4 red, 10 green; 15 blue, 11 red; 14 green, 5 red, 6 blue; 12 red, 3 blue, 13 green; 9 red, 10 green, 6 blue -Game 94: 14 red, 10 green; 15 red; 4 red; 4 green, 7 red, 1 blue; 6 red, 5 green; 1 red, 2 green -Game 95: 1 blue, 11 red; 15 red, 1 blue, 3 green; 13 red, 2 blue, 3 green; 1 green, 1 blue -Game 96: 4 red, 4 blue, 4 green; 5 blue, 5 green, 4 red; 2 red, 8 blue; 16 red, 5 green, 13 blue -Game 97: 6 red, 13 green, 3 blue; 10 green, 4 blue; 3 red, 12 green, 4 blue; 3 red, 5 blue, 16 green; 3 red, 9 green, 1 blue -Game 98: 8 red, 12 green, 2 blue; 7 green, 8 red, 1 blue; 2 blue, 6 red, 3 green; 9 red, 1 blue, 4 green -Game 99: 6 blue, 11 red, 7 green; 9 red, 6 green, 1 blue; 9 red, 2 blue -Game 100: 1 red, 4 blue, 2 green; 6 red, 2 green, 11 blue; 1 red, 1 blue, 2 green; 1 red, 7 blue diff --git a/2023/day2/solve.py b/2023/day2/solve.py deleted file mode 100644 index 939b134..0000000 --- a/2023/day2/solve.py +++ /dev/null @@ -1,24 +0,0 @@ -def main(): - max_seen_colors = [] - id_sum = 0 - - with open("input", "r") as f: - for line in f: - current_game = {"red": 0, "green": 0, "blue": 0} - line_relevant = line.strip()[line.find(":") + 2:] - for grab in line_relevant.split("; "): - for items_saw in grab.split(", "): - count_and_color = items_saw.split(" ") - current_game[count_and_color[1]] = max(current_game[count_and_color[1]], int(count_and_color[0])) - - max_seen_colors.append(current_game) - - for ii, elem in enumerate(max_seen_colors): - if elem["red"] <= 12 and elem["green"] <= 13 and elem["blue"] <= 14: - id_sum += ii + 1 - - print(id_sum) - - -if __name__ == '__main__': - main() diff --git a/2023/day2/solve2.py b/2023/day2/solve2.py deleted file mode 100644 index c79821a..0000000 --- a/2023/day2/solve2.py +++ /dev/null @@ -1,23 +0,0 @@ -def main(): - max_seen_colors = [] - power_sum = 0 - - with open("input", "r") as f: - for line in f: - current_game = {"red": 0, "green": 0, "blue": 0} - line_relevant = line.strip()[line.find(":") + 2:] - for grab in line_relevant.split("; "): - for items_saw in grab.split(", "): - count_and_color = items_saw.split(" ") - current_game[count_and_color[1]] = max(current_game[count_and_color[1]], int(count_and_color[0])) - - max_seen_colors.append(current_game) - - for elem in max_seen_colors: - power_sum += elem["red"] * elem["green"] * elem["blue"] - - print(power_sum) - - -if __name__ == '__main__': - main() diff --git a/2023/day3/input b/2023/day3/input deleted file mode 100644 index e51b04f..0000000 --- a/2023/day3/input +++ /dev/null @@ -1,140 +0,0 @@ -.......497...........................858...923...128..................227..801........487.....664........................................... -436........765..............140.......+....................859.............*.........+.................960........668....................... -...*982...........=..........=....203......266.263...375*....=...402....691..-....................*..........575....................13...... -.............114...588...............*............*......631........*.......952...463..14.......661..........=...706......*333.........595.. -...194.........*..............743...917.&......375.....................................*...............544*.......*....664.................. -...*.....807..452....81..........*......969..#......309*................/....873....941...828.197..........427.728...............566...13... -.243........*.....80.......329....470.......145.475.....111........*659..259....+........*....%........569..............%.....*....*....*... -.........130......*....385*............123......................199.......................640.....463..%.........978....920...266..380.83... -.....323........870.........+...........$.........466......453........................297...........*............*.......................... -........*.=..............588.....*786......$.........*........*.......390*.....886...*....227...728..852.......606....*863.......916..396... -.....538...287................301........133.....539..........33.537......466..$...793..+..........*...............218.....721........*..... -...............986.........=.......................................*...%...............222..-.......701.271...............#.........437..... -......*3.........*.626.68...419...740...........................806...976.......875.........174..............735.............=488........... -...790.........487....*................./532..13............................*....-.....503..........*11..734..........978.19......622....... -...................&....712.68=.619+.........*.......................863...596.....2.....*.......160.....+...&659........*.........-....-757 -437*.......#........520...*..........304....568.974.255.318.183.........*.......&.....675......................................849.......... -....161.....687.710.....854.............*.......*......*....&...441......891.....476..........616.......$........235..434.880...*..673+..... -..................*...............683.....800.120..............*....807..................................707.....*....-....*...74........562 -....@...#988...487..#685..........-......*..............251.146.............................142@....74...........398....769..........238*... -....848....../................-.$.....662.........773..*...........895.......591...........................233.............................. -797.........611..........@.186...429..........304*....468.....554....*..........*...960......82.......*810...+.534..660....645...313./...... -......239..............509...............720*......................844..939=..508......*...........401............*.......*.......*...649... -........=........158.......$.....=...........200......409....982.....................46................126.....517....303.647.660........... -...530....=......*..........704.69...................*.......*..................@879........589..131.................*........*............. -......*..871...672....................611*........415.......283.569.21....842/........-109.&.......*.......157$...719.......679.$........... -....664..............664......668.........203....................&...%............................14..................427.......833..484.... -....................*........*.......434.......796...........65............................................-479.126..*..............+....... -.....382..........121.....836.........*........@...............*789.......624........350&..........*544............$.6.........882....513... -....%.....406.........................848........625...%...88.........382..+..971.................5......*622...........914....*....%....... -..............627....816........641..............*.....373./.............*..../...912..651.162........557........901...&.....503.337....59.. -...357...........*.........552...*..816..........240......................636.....*...*.....*.............@..993....*....................... -......*934....961...=..43..*...324.....@...............726.888....370...........170.805...517........639.389....*..929.................953.. -.16...............408.*...94..................................*......&..............................*......../...9........605............... -.......571....13......512........591+.......976.......895....489...........751.......474.760.........240.....931............*............... -...464../..................608..............*........*................$.94*........................................486.......172............ -...*......121........=.....*.......$......909.......583............128........929...................765.............*............+....24.... -.............*.......762....230..422..285.....434......................390.....=.....921.................261....#...949.....382...903.*..... -............595........................*.......*...................833*..............%.......973..$....@...*.268........506*..........251... -967...................................25....234...........................306....281..........=..36..918.432....../406........344...$....... -.....700*610.......=...839......917......33......610@................537....=....@............................%........20.402.@.....926..... -..............%.768...*....................*...@............93..161.%...............74$......%.........96..298..........%..+............+519 -...........925.......586...................264..85...721....*...*.............................371.................822.=..................... -...............540...........-....447....................987.....305.............379@.707..............670...397...*..842....552.464........ -.....666......*....844....515.......*..............+114..............977...............&...393........*.........$.800...........*........... -.....*...647...696..*..............203....................418.....19............522........*.......462................57...786..........561. -....691.....$.......756...165.....................596.32...%........#..280.259$..........398..............425.............*....719..796..... -.............../.........=........1/..305............*.........451......&..........332.......706............&.......327.841...........*..... -.74..........791.............=........+.....................+...-..................+..........*.....................*...............419..371 -...*927..........352.......148..........401....459...+....998......$783........@............444..$.......959..106.366....................... -............190..........*......385.............*....846......................907.826..585.......447.441..*..*............7......871........ -.................142....944....$.................634.............587..@..930..........*......935.....*...819.29.....3......*35.............. -......967....415*......................=980.....................%....58.-......317..74......../.....922..............-.207........../....... -.........................................................................................................175....................369.233..... -.........................+....645.$........%.....620.+429....951......616.................................*............524$................. -....799...551*602........920..+....503..654....-...*............*....=......395.........451....263.......897..................370........... -......-.......................................409......970....661.............*............+...*....48...................475..$........839.. -..97...................../.....@497....%..........446$...*...............533..794.....432-.....167...*.....722...486........*...500...*..... -..............459......540.............110................569............&..................#.....................#........785.*.......455.. -........815....*...........................*452......./......................365.........929....*978.=................709........+..84...... -....427*......466.............608*796..............680......................*......&.........142.....603.................#......621..*...... -.........635............@....................302..................296-.....679...801..290..................464..............980......627.... -....../.../........%...850.......*108....513*........656...*739........715...............@.......713.......*...................*............ -354+..245.......629...........995.....................$..41.....=.....@.....................45..........840......506+...$.....148........... -..........995.................................&541............914.510.....950...../...........*53..28...................275........138...... -.............*812..665...../.........................101.308..............*......691.482.............*........902.585.......@.......*....... -.........../........./...292...............#..........-....*....@307......661..........*.210......135....932%...........992..54..191..931... -...400..649...............................504.196.........88........................581.............................743*.............&...... -...*.........140..............642....891.............309...............................................695......361..............603........ -....170.643#..*.................*....*.......*24.....*....................932.291.....538....461.........*........*..275............&....... -.............725......494......23...279...713..../....449............*........*...../...=......*..........434..............785.............. -.....991..........946.............................830.........136.439.24...519......289.......408...579........708.650*......*.370.13....410 -......*..887........#..688.673.........218......................-...............941....................$.......%.......927.722....*......... -....124....*...........*..../....427....*.............312................................................922...........................307.. -...........706...16..934..*.......*......608....459..&..........761.....................647..641...........*.............242............*... -..5*715..-........+........122.....262........./...........928....%............728..610*......*..502.....222..40.....923..+...........540... -.........701.............=..............291...............*.........351.........*............141.%............*.../.....*....725............ -..............314.......878....%.......*......=..820*.....988..204.....-.....889......119............797...........395....+.............287. -..................671........322....101......257.....733........@.....................=.............*..........544......600.......862....... -..421.......582...%..............................484...............565.....+...831...........695...384.#...592.=............240....../.904.. -....*..........*........570...........&....=........*629......717&.*.......93......726../961....*......535..*........767../......715....*... -....439.....630............../..%...615...912......................777............*..............602.........567..3........107....$..77..... -....................914.....3...2.=.............763...&885......................185....182.......................*......-......+............ -...372...383........*..............60.............*............&..38.681...............*.....459....../........117...504......358..480-..... -............+.990..33...........................834.......@..33......................494....*........181.66+................................ -...............*......*...492..............176..........857...........376.315................954.....................*982.......763......... -329=..........179....245...*...61...........*...*................%......+....*.....352*509.........952#..69..620..423.............*......... -.........................131.....*17......191.33.306...../.....144..503......491.............................................298...415...... -...................$...................................426.........*...............526.669.....&498..698...$............447.....+........... -.............575...142.617......890..............%...............212..730.519.971..&......*384.........@....18.219.........*................ -.......*537..*.........*........*.........677...587..407...120*........./....*...................................+......334..........700.... -....944......636..848........743.....388..*....................109..........................................................540.40..*....... -.................*....596............*....155..324...820.520.................=...............443...94...........621.276......*..+..910...... -...............276.....-.........376...........*........*....................739......368....=..............428....*......434..........878.. -932....28.....................-..=....207......959....................289.........196.*........................*...............-.......=.... -...*........................172....#.#.....688.........25..944...725...&............*..110.....148...426.483..771../932......800............ -.947............................457....931*.............-....*...#.......834......721.........*.........*.............................477... -.....*491......*.........*114.................191.....$...213........909*...................194............633....%...792..605.633...#...... -.............108......611.....+719...........*.....696........865...............120................=724...%....950.../......*...../......... -...320............*.................260/...121.........338...*........719.180.........516.....*.............................649............. -.....#...643.......941......*160......................*......140...94....*...............*..39.789................*......&.........81...597. -............*..135.......532.................%90...608............*............+515....743.............+...194.993.669..259..+.............. -.....%....948.....*............262..695.712....................623.....*...................473........602...*...............83......679..... -..259.............447.............%.*...............363.............105...................@........=......+.........................*....... -......957....659........299..........................%...599..898.+.................464.......606.237..768..416@....=...............228..... -.376..$.........*..........*..2.........@557......./.......*.*.....517..........859*.........*....................855...877.427.........*... -.........*468..535......500....$................117......726.381........428...$................@........43....472.......*...*...........476. -......517................................951........%............-..249..@.....920...........859........*........*....825.393...15.......... -...........770.......&16.....278...417......$.....626...-23....954.....#..............................868.......502............*............ -.....373..*...................%...*.....254................................................246.#530....................982....179....635.... -......*...538.....................362...-...........162.........................180=........*..................278.......*............+..... -....138.......922..............................543................6....12....&.............92...150...............*.......994............... -................+.....+................388....*..........................*....788............../..................220.............834....... -.....................301.593.597.............500..603......928....966................/.............536.......768.............800............ -................*64........*.../..&.....924.........*........-...$....................203.............-...+..../...............*..423.&451.. -.............453....*......638.....314..*...896....459...............96...................186............581................846....*........ -....&188.........624.400...............268....@...........................664...............*...12.943............#733...................... -.............................597...765................388......149..468.....+............698......*....143........................426....... -.......................878...*.........875..............*..871*.....*..............929....................$.504*..............473.%......... -...245..........94.651..*.....915.........*.........40.440........236.................*511.45........994........753..................887.... -...#..............*.....459............212...18*964.*.........=71..........768..827............./.....*......................567............ -.....787.2..781*....................................827....................*...*..............437.....813.......317.....102.....*333........ -..........*.....285............@..-...........304.......821.622.....953...377.997......320....................@./.....%....*..........254... -.......877..636.....42......772..419.....189..*................&....*.....................=.17......366*....563......228...153.............. -...............*.....$................&....*...839......218.........449......................*..409.....69............................652... -.....576......255..............593...397............469..%......#.......+568.......374......499....*...........541..477.........%137..*..... -.......*............@319.................$.35..........*.....207...............808*.................933.737...........*.502............367.. -.....807....219../.....................436......226@...266........215...................................*................................... -..............*...769.....41*....922............................$..*.......271.........350..........677.346......................662....725. -..............175............979.*...#........215..............652..39......$....=61......*..154...................................*........ -...426..............335*.........487.194.........*42...................790.............+.750.@......&..............253...337....617..717.... -...+....908.............489.................../............14...278.../....953.......316.......*856.44.50...../.......*................$.... -.........%..90.................437..........848...........................*......714........708..........*223.588.....884....871.801........ -494@..........*..33...........*.........779.....424.550....923............779.......*...340........738.......................*....*..131.603 -.....50..481.........=.....643...........@......%............*.......815......681..263....*........*...5.....256*11.377$....872.903.*....... -.....*...............635.......698..........583...148........708........................323.243..201.....................*..........377.132. -...502........883............/..*..............$...*....994.........*....479@.................$......804.443..........584................... -.............*..............893..581..534........376..+..........174.119.........138............670...*....$.834............4............... -.....+....234...904.323..=..............&.894..........439.@838............*.....*........47........555........*............*........932.... -...594............*...$.654.....+.........*........................84.*....7...231.$102.......286.......*760....817.......719.........*..... -..................620............806......866.................559......440...........................310...........................590..547. \ No newline at end of file diff --git a/2023/day3/input_test b/2023/day3/input_test deleted file mode 100644 index 624ea4f..0000000 --- a/2023/day3/input_test +++ /dev/null @@ -1,10 +0,0 @@ -467..114.. -...*...... -..35..633. -......#... -617*...... -.....+.58. -..592..... -......755. -...$.*.... -.664.598.. \ No newline at end of file diff --git a/2023/day3/solve.py b/2023/day3/solve.py deleted file mode 100644 index bc84dc0..0000000 --- a/2023/day3/solve.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List - -def is_part_number(lines:List[str], column_count: int, row_pos: int, column_start: int, column_end: int) -> bool: - min_column = max(column_start - 1, 0) - min_row = max(row_pos - 1, 0) - max_column = min(column_end + 1, column_count - 1) - max_row = min(row_pos + 1, len(lines) - 1) - - for row_idx in range(min_row, max_row + 1): - for col_idx in range(min_column, max_column + 1): - char = lines[row_idx][col_idx] - if char != "." and not char.isdigit(): - return True - - return False - -def add_if_part_number(result: int, lines:List[str], column_count: int, row_pos: int, column_start: int, column_end: int) -> int: - if is_part_number(lines, column_count, row_pos, column_start, column_end): - result += int(lines[row_pos][column_start:column_end + 1]) - - return result - - -data = [] -with open("input") as f: - for line in f.readlines(): - data.append(line.strip()) - -result = 0 - -columns = len(data[0]) -for row_idx, line in enumerate(data): - number_start_idx = -1 - for ii in range(columns): - if line[ii].isdigit(): - if number_start_idx == -1: - number_start_idx = ii - elif number_start_idx != -1: - result = add_if_part_number(result, data, columns, row_idx, number_start_idx, ii - 1) - number_start_idx = -1 - - if number_start_idx != -1: - result = add_if_part_number(result, data, columns, row_idx, number_start_idx, columns - 1) - -print(result) - diff --git a/2023/day3/solve2.py b/2023/day3/solve2.py deleted file mode 100644 index 5b23f13..0000000 --- a/2023/day3/solve2.py +++ /dev/null @@ -1,104 +0,0 @@ -class Gear: - def __init__(self, line_idx, column_idx): - self.line_idx = line_idx - self.column_idx = column_idx - self.connecting_parts = [] - - -def add_part_to_gear(line_idx, column_idx, part_number_line_idx, part_number_column_idx, gears): - for gear in gears: - if gear.line_idx == line_idx and gear.column_idx == column_idx: - gear.connecting_parts.append((part_number_line_idx, part_number_column_idx)) - break - else: - new_gear = Gear(line_idx, column_idx) - new_gear.connecting_parts.append((part_number_line_idx, part_number_column_idx)) - gears.append(new_gear) - - -def check_if_part_number(line_index, column_index, lines, gears): - ret_val = False - - current_line = lines[line_index] - if column_index > 0 and current_line[column_index - 1] != ".": - if current_line[column_index - 1] == "*": - add_part_to_gear(line_index, column_index - 1, line_index, column_index, gears) - ret_val = True - - max_column_index = column_index - for index in range(column_index + 1, len(current_line)): - if not current_line[index].isdigit(): - break - max_column_index = index - - if max_column_index + 1 < len(current_line) and current_line[max_column_index + 1] != ".": - if current_line[max_column_index + 1] == "*": - add_part_to_gear(line_index, column_index + 1, line_index, column_index, gears) - ret_val = True - - min_other_column_index = max(column_index - 1, 0) - max_other_column_index = min(max_column_index + 1, len(current_line) - 1) - - if line_index > 0: - other_line = lines[line_index - 1] - for current_column_index in range(min_other_column_index, max_other_column_index + 1): - other_char = other_line[current_column_index] - if not other_char.isdigit() and other_char != ".": - if other_char == "*": - add_part_to_gear(line_index - 1, current_column_index, line_index, column_index, gears) - ret_val = True - - if line_index + 1 < len(lines): - other_line = lines[line_index + 1] - for current_column_index in range(min_other_column_index, max_other_column_index + 1): - other_char = other_line[current_column_index] - if not other_char.isdigit() and other_char != ".": - if other_char == "*": - add_part_to_gear(line_index + 1, current_column_index, line_index, column_index, gears) - ret_val = True - - return ret_val - - -def main(): - lines = [] - positions = [] - gears = [] - with open("input", "r") as f: - for line in f: - lines.append(line.strip()) - - part_numbers = [] - - parsed_number = None - is_part_number_parsed = False - for line_index, line in enumerate(lines): - for column_index, char in enumerate(line): - if not char.isdigit(): - if is_part_number_parsed: - part_numbers.append(int(parsed_number)) - - parsed_number = None - is_part_number_parsed = False - elif parsed_number is not None: - parsed_number += char - else: - parsed_number = char - is_part_number_parsed = check_if_part_number(line_index, column_index, lines, gears) - if is_part_number_parsed: - positions.append((line_index, column_index)) - - if is_part_number_parsed: - part_numbers.append(int(parsed_number)) - parsed_number = None - is_part_number_parsed = False - - gears = [gear for gear in gears if len(gear.connecting_parts) == 2] - ratios = [] - for gear in gears: - ratios.append(part_numbers[positions.index(gear.connecting_parts[0])] * part_numbers[positions.index(gear.connecting_parts[1])]) - print(sum(ratios)) - - -if __name__ == '__main__': - main() -- cgit v1.2.3-70-g09d2