commit 83ae8027899a0dd2e8e8ac3d59faacbcae60d4c8 Author: Alexander "Arav" Andreev Date: Sat Dec 2 17:34:17 2023 +0400 Init commit with a complete day 1. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5e82d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c33ef2e --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +CC=cc + +CFLAGS=-static --std=c2x -O3 -Wall -Werror -Wextra -pedantic + +EXES = $(wildcard day*) + +all: create_bin_dir $(EXES) + +create_bin_dir: + @mkdir -p bin + +day1: day1/p1.c day1/p2.c + ${CC} ${CFLAGS} $@/p1.c -o bin/$@p1 + ${CC} ${CFLAGS} $@/p2.c -o bin/$@p2 + + +clean: + rm -f bin/day*p* \ No newline at end of file diff --git a/day1/in.my b/day1/in.my new file mode 100644 index 0000000..c11e57f --- /dev/null +++ b/day1/in.my @@ -0,0 +1,1000 @@ +mxmkjvgsdzfhseightonetwoeight7 +3five4s84four9rtbzllggz +75sevenzdrpkv1onetwo +3q7ctkghhqkpb5four +ccxpblrgrjxcgrhjxfmtwonine8eightzzrdn4 +6lqjrhbnxxcqlpnmjsthreesixxsxcgqsxmdx7 +35llbrhh +fivethreejcqpfqmcmvjlmhlbzpxlsmktzkmtmv8p +3369eightnine89 +onesix4qqnlzdsevennmmrcgkndlsgm3 +two4xgdjdqtcjk1threelkjdxvfivesix +sixsix6njhqrnine +4skbhsbtqc +one11fpkjsix +kgtkgdjtwo6mmklqc +kqfqq39gnncltrtpgtwo5bxmx +jdqgmr5jtz +6hltxnninesmfzpnqjnkcrstv +twotwo6eightqcncghjvqfcv5 +4ppzhcvqrnkqonehlhlcqmrq +1xldgvsix67 +2six1bsxxgbonefour +stwone3qlrfive314sixsix +tfkbqvreight34r +five4eight +rvsmznr4eightjqckcr6nine6rhpnmxrhdc +xpqldjttwompcfseven8seven8two +fourclkthghllzlhrs31 +2hpmvfbm8seven5v58 +3qnfqtgndveightthree +fivethreervmhvzgeightvzc63 +hlpsp9nqnsvhdcfourfivestcz +nineninedtfivefive4 +gb9twoseven +1fourfive4seveng +tmlsix2fiveninefourgjltplkfcnine +one3sdrckqtzdzgvtl7vtwo +s2fdklslhzrxktzzttxdtnx1 +three8vhssix9hhtrxkbpjp39mcchnpp +37three5btqxsqkszchfivebvbbddssvc +z5onefour +3eightrthplstr2gbbkddhdqvctlsj +zmtfdb9 +4d +fivetwo9 +sevensevenonefour9fgm +rcqnineseven2 +sevenjssstgtdn47 +34jbdxspph +zthreeeight9sdnzqqhnpvdrmpfq +8nineoneoneoneeight +k3 +sevenfive4sixninesxflqs2 +8hplbktr +sevenfive6nsmqrmflsfxctgjx +954mpcnggqmv +four9four +185qhonezszbfive +oneninetwosix3eightb21 +sixqrhphxsvj15three +43jnvvlsqsvk +oneqxvjlddgfkgjdjgpvcvz5 +lkkgzfbdsjzpslnqseven12ninedxhtjgx +1nine62fivefmxvgr7 +s32eight3seven9nine +eightldxdrtwo1krrnj8vdrchq +gmdm81 +five7two36dzgqninef +2four4461three +fourshbdbvsixklsdgggb6 +bfsfl1 +5bnvzgtbrsngdbqldmzlhk4 +seven1tbjfkmqdpmlkfmqcjl3bzhzfk +22rmsfjstcglnrnninefivesbglz +6sixssg915jthkkfhj +fourseven81945 +4s5two +bzrnthreephhptdvfourjbsteighthkzqbtlczmkjrmh9 +eight5zsbnine3tgllxqjbf8 +2twotwotlgdbnstp7hvgpkgvdkmmzpzf +sixfourr9onelfzvfm4 +lgsmmjmnl713339sdfour +threefive9fivenine7nine +eight68four5threeseven6two +sixeightnfkrzxlvfx5drhptm +3one7jqtpzggzplphrzbnplnfivefour +eightcqksvtdzmsjssnjtf5eight1 +2three4tzzlv +1zfctfccn1fourhnmnklgtwo3nine +ninembcfmxnkqb1four46kgddneightfgxsnkzd +qpjbjmhkclkcznkx1ninefivesix5eight +njhpf5ninefive +7jtwo +two79mvmtbthreesix +threeqcnhzcfk7five8jnk1 +kcdflseven69 +eightninekpjpcbhd4 +3five2ghlgr +615pgtjhqqttsixone8six +nxsqklg3three8 +fourtwo889nzfnqckbpslone +mtzzpfour4pxftwo +phzgbcghsixclrrrfourseven3 +cqpccvmvqnine56mmmtqfp +gdzrsxdhklrlpmkjqzd8 +1fjltwo +fivethree9 +6512krnnxdxzprbtlgcfoneeightwohfl +toneightfive5two +4sixbrcbxq +4hphcpfxppdnhxrmlhfourxfkjb +tdgpntzgz36 +8zhtrnglsix6sixhdlqkfrzvmcztwo4 +xjxph74 +three3qs7sevenpkjone18twonek +fiveseven4 +2eightrlnine8eightrbjpml3nine +fourninethree2three5four4 +rmrvbjblcjpdpvckprzdrdpbdtcmrndhphbbhxpzmtwo53bdxzcn +cvdpnd89four +168five +eightg29tgvfqdzmgstvbtftfour79 +foursevennvmgqvxhvg6seven +6one57onefour6 +one7ninethldxfvthree86dfjxq +bjeightwo7fourfive +jmone3946eightwor +fivexrqhzmsix9four +hldhs2vhtljcqbsseveneight +ninefivenine2fiveb +3hqzninenine +nnpd7seven8 +51mfkr1gjzrcrx6fpsdg7six +zxthreexfzfzckhhggtwo7 +bvmspnxl9mslb8fiveninetwo2seven +nrgmcfgzcthreefivenvvnxzonenine91jsvfkhv +threethree5four +7vclcnxdnmxqc4twobx +22qsthnkclllmlcmthree +1hz2xeightseven3cpbjtpv +65hpvfkkeight2 +eight69 +6sixslschzjxs8rlgjkbqjzhhx2seven +9qdhjctdfzzqv2eightthreexfl +oneqjtbnn68seven +hdzmhfsvch422mcb1one5 +55nine3sevensixfive +lxjrrhkdztwonvmgbbkqxpxgtwo7vdvvzh +kcfctfdpfnseven87ninesixsjkxxn +2twoeighthqllthree +dgjkvnbrh89 +pxmbhhtlmqhdbqkxftk4cx6rljkgx +9seventwoeight65mvmgpfxtrghzd +hd3vhbxgpsevennzhlzseven6 +83one +2kztrbbkj2cmjzm7 +1sdzkctzqtwo +6vxjgvmsz1onepgdkrtrd +52kmspbvqbpzbscjtzkm79onelhzrfmp +1259one4gztcz +jlmrvtxjphtwo2 +zrldjg2two +sixdhsfvqrnseven5ms1 +gmrdkgqb8lmlpzjfflsbkjnntjc9eightcdpdq +4nvxdvgjrnzdtblhxfsvdpvm3seven1tlkhfzmjqp +dxjjbv4lvc39bscvppc91 +c6 +dvftxktvsonehcprkszlbfive1jxckpvknfthxnsm2 +drglpjtm1fivesixccr +five35ksnljjnpdnine +three92 +3hbsgfrxqxgpsbsevencxthree5 +1flnzjsseven2 +176eight6tskbvc +5seventhreesixfivebqtjtwoneff +kghrvxcpgplfdrxxtflbfffivetwo1fourseven +nine1twothreezjrmdcsclgfourtqbstp +ffggc4 +sevendqhkddzpvxsix92jncd +hzgcggpgn867mmvtvd193 +9qkgzfd +sixcrkcrhgpj3497935 +eight4pmknqkklc +sixoneonerxqpfljvleightsix2eight3 +fourfivegznjlplsmpjrbhd61lone +threeseven1one1two8 +986lsixdqkpljbx8 +lggq8fouroneftp5 +loneightfivethreemfn19 +eightseventwo29four +5phtlbfdbltbls99699 +8lnbqbslmqmhkvzvnkmxhllpngcm9one8oneightz +vfqprdmklzgklllm362tcdvvlmvdnjsixeight +2dbltlmcxklxqlvhgmkkgfr +five31468threercbjkvtqgm +ngzpnljmdcrqt86hphtnblsxmg5tnsltm +4mtzpfxrzrrdltjbmgjksix +qztnrrsgkrsskdvj4skfnx6 +571four +1eightxd3 +2four98n366k +sixbbztnkf3fourfourhvs5nine +jsftxsix4ninethreetwok +9mbskphxtmpthree6nine +bm6fourghmnrnsmtwotwofournssrseven +9bnkcmdpsssix48 +fivefourptglzp9 +14gmrfdjmkbjlnine +threetqq3 +two474two4 +tdctzcztgnthreefive1sevenxfqzcjcj +8tph1sevenone9thppone +six3ntvjfgdv6seven +77nine1twobszrsjffqcvhqv +19123threesixone +83sixsixtwoseven6 +cjqnine3btn +gjdlvzct1 +498bvcdrznineonetwo +rmcnshlzxlthmtfjqdn3ktwonem +three9one9ninesevenzpv5 +qtfv1fivefourthreet3one +ldpb7three +fxfrxbhfour9nine25threejkmthznj1 +7three19rffgprxfjzk4 +four91 +mfbfhnh771two9eight +5rhrseven +4three2sevenone +eight58 +eight6one54np +ncc4two9646 +xgboneight4 +7373ngvsgr +foursevendhtgrlrtflxvlonezxxrghjgrzpcmrkdxhtchs9 +mfoursixcneight188 +3xlpkjshjz +sbppcxpnxkjm3fivenrmqzkcdrz9eight9 +eight8threek38eightlfzone +1lpfhddpqsevennine2four +rvnjdqkj6eightsixdxjbt2 +46sixsix +8eighttwocscdgpsz119bdv +1nkmvbcgxs9ninesix68czshseven +sixtfx9 +threetbksevenone1tzmsvspqjhtwotjfdqt +ktztwoseventscssk14 +4z4 +zfd998threekvonebgpxtqxv9 +onesevenone3 +three5fivepzsqvm2 +srvbvkb7one7threejmmlxjvxcnxqggcvtk5 +mvcsix2onegfzzrrqsixeightsevenpmmbmdqvfq +1fsxsnhrpkfh5xcphtfmjdb +91tqmbkxjhg +threefivenfjz1eight5sixseven +5eightfive +4fiveblhqn +23seventhreesevenfour +twofourkqgone2cmtkzldj8 +deightwomqvlxpvthreetwotwof8 +seven7lrrtlsxmpngvstfk9 +threeknchdjnine3k +2fourfourvhnqthfivevbzsfcseven +frfxctwodzjlqcqfj319 +fz7three +mmn8sixtxmgtwothreeprk3eightwoznl +2xjsevenct +551sixkhd +3sevensfck64two +2pmxrtkzrsix26lrtwo +jlqbhmsvmthreefive2tdpjgqgngjjsgmpsix8 +tgtfqplcrsseven1skpfnr8cfrxvn7 +mvpl755three2seventwothree +3b +cdfjmnkjsix2twoeight5gsxsc +3l3gqcmjhtk +9mlftpmmlqctonegpbfstpcnhmm53 +4ninedbztjvvqone5zcnqhh +six5n2tzzhvll2eight +mfcb81phsqmczzsix +cm41oneseven3 +vkkgh2fqs +seven8dhfkghhsix +7jnqxnrvbsg54sixtwonedn +stvsix2leightprsllnlmtjqc6seven +four2threenine4onethree +fiveqqhfivenine9 +four85two8 +5two756twooneightr +679 +xlbbxrhkt4dqdcbkddoneoneightjb +6sixthreethreefdzjcqjgjpxfour5 +deightwosix4six51seven +dkgkgjhc6sevensevenninefivepvbrthreetz +rdqxbbninefvkvdhmgr61nineeight +3nzdvnljf71fiveeight +zcscbkleightvvtxbqbgmr361 +mqhxninebtfrfour9eight8six4 +onezdfdc351 +rrtwonesixtn4eight23 +sevenfivethreezmbjmfiveeight4four +pmfpfjhs58eight +six88tvdsxdll +four8cgm3eight +pprsdrtwokk9seven +sddbkzfczc9 +qsevenone6hc47jbzvpbgj +3hpdmbpmrtrzhkdfivecpdcgqcnfcfiverrhksnpcd +7six946 +nqptzsixsnpqqmjpzmgfheight3 +2fdlprcxtrn +73lnine9 +eight2mrkrqfive +sevenllscmf6sjqbjvdqzd8khxvpninezctzf8 +33xdseven5436 +mnbhzx3threeonetwoone +sixsixtwoxrhfive79 +eightzdbm7sevenzhtl +djlmh9threefour +six7xmlg89 +seven97sixsix4hsgzlm9 +6eightsix2m +tnrzjjxggd9zjckhbrhmvfouronetwo6 +cdhjfvnine82sixonefourdkpsg4 +65vrsvponenine +fivelkpvpone9gjqxf1ninesevenkfrkjqkfb +7twoqst +mggftm2five99four +threeonejjshqfeight3three74 +1h97lfnvdgqlhjmqbqffive +bk88nine +eightone2three7 +3hsvjpfrpv +5sixtwoeightltnvmzsb +3zxqrfkgc +two93njsmdsixsevenfournklz8 +6nlmtheightdjsnklrpbb +3threelpbznvzghpnrveightsixseven +4djqnvrksmdrgfnqglg3two +411vqljd3 +7ninelmbqlthree +two35ninefnhfrsixfive6qzlptcpgh +four1pmkfcpkh8nine +1gzfgmbqbmpqr1tvkrntdn +5sevenseveneightfour4zttvtwolnrkqd +1sfouronepgmckxvhtwo69 +jmbqfour1eightwot +sixonevq5 +r3sixmn +rhklqpztgcvxthreesix5onevf77 +5nnzbzjcpc +twockmmkdpcmhbczbkp2six +95eight57seven +bctwone7one8threexspzds +ninesevenfivevsnxzfxdmf9z995 +7five8gmhlqjvtrqlqgrlngmx4 +gfftcpxeight46 +1nine9two1eight58fxhtmv +1pmpxzsevenjhxpjmxbfourfour +7oneeightpzkzzczg +onenine3threeeightjd9 +fourninecvbmcsctblfour46eightncgkjgt8 +9threesix +sixonesixqdqqjprfourone62 +deightwofourhdb6eight6 +52six4jtlphxslh8 +4tsdjnkqkcrtwo4 +6two5rbggpdz9ninesixjctmfkdhz +xtftfgvkcp1foureight +oneqvdphhjzqmqdb8 +8two8slfvgbqqhq +bnnzlseven41l25sevenb +8smzbc +941eight +vlcszrbhssdhvkcfcnpffhone7four1 +threesix4hcsnpdfqksfour5three +7lcnbkbdfmninenmmrffgbrfour +5hlr8flfldblp4three5twopctglmcq +3sevenfgvgxxsxdvlbkkhr9 +5sfive +8fourtwomqtmchfjbkcgpntjpkkkp +mkjxmqsevennmsspqhzxmrncpstpbfour77jbfz +8nineone1513 +hgsqzrqcbnjcbdtnlfljnm4four +cxqnqseven7gmqpffmxgkxdtwo49 +rndoneightccsjmklbxf8tgqph +twon4 +nsccmbthreebdtjpsixpdc5xbxqqgzf2 +sixglxmmjdvqx9eightntpeightpgzxv7 +pvdtwone8five5tvdlshqnrd884 +fivebfrvnthreecjlzhpglvfphhsix4 +cfnfsf9hrxvpfdvbbfourr949 +3five2psng4 +fourkbbfzlqlvhm3 +zvfqkpzctpreight7threeonehzfxnkj7 +three8one +16eightsevensix32nine +nbgqpspvdtsixjkv6cqzpq +sevenfdfhgrzthree2 +nineqxthree1 +onehmgdksxkninekbbrphbmt6 +5pnrlg7drhdthree925 +two32tqtqk6 +fsknktltdb32seven9 +5464fqtghjrqdpeightvzbx +92five6scnddkj59 +vrmfoneone93four +bbbbzfggtd5qzmnlqxssfour7phfjtjjjtggdmpfgzjssvjbgsr +gncbxjpone22tvfive +6six9eightjjnvnhdxtjfouronefjbsq +tconefsnseveneight47six +hkh4 +3hshtz2seven72one3 +5sevenqqbttbjfdnhlrksthreefive1 +qzcggcmq89qjcglscsp37eightthreepbhdrnbkf +6xjsxlbldc +7s4sevensix6 +5twoeight85threefour +6threekbg7 +3134 +sixtgvxcvfhd1tj +8sevenxzeightrrdvnpf38nine +93three +eight4nfrsjq4eight5 +fournvpfvmqp5 +7fourxvljqmkmshdlczkrhqhmvtwonehn +qlxq1frdbgrvccnn +threesix8ngkjtbtv9 +4r +five8three4ptcnv7 +lnb45xgd +9lbpclmj4gpxrtmvvdeight7 +three9two3threeknrbxpd6dnf +5pqk41sevenmqhvcdpllfour9 +86qlxmrghxlcthreebphtqpdrbj +three6ninevvpfzr24 +eight4zq1vkqdzfjjxqrdxdkgpcp +8hrvgrzcvvchjt8fxgpqngjstpkqmjkmjgdnrvtxmdzzfour +rknoneightcmdbr1 +5vsix6 +ninemttonefour4threevjzmsix +5six5shjhxbplmttbpts +vsevenonefourrlgvfbfsjmbfzxm3 +8141fourvxzgvfxx9qkdkbdoneightrdl +twothree6 +mfpqj6onemtvrnbbgphz +99eightzdnctk +5zrcrsbthreetwoqqrjtzprnvqczxj3 +7sevencgcnjdlnnlfivethreepmnjjjmkqzkvqgf3three +onetjqqcxhksmnb3onefive +2fourthree5foursczlj7fxpfscc7 +qmlf7 +19eight +fivefour2 +onetwofourone3hhffourtwo9 +8threesevenhhtfllrn2 +eight7pcspzljx2msplsg6bdk +eightbknvftrbcsixnine4threemppgcdfzhrxcmlqlq +one46 +3r +5tpvkrxmthreedn4sfseven +48two +s3nkkxzrj +14jfrbrxr +4618 +1nnthreesix +szsmxqcfh1 +ninesevensix4onefbckbkc +ninefour8 +sfxkhrqbndtrrknhchxzqone9three +xxzoneightfivebffhhnk27nn +1threethreeninetwotnbjftcnl +7two58 +22vbljflmgxrdtqgxchsthrstg2l +5lklmmcfkdm12dxsix +threetjsr1 +qcponeight3six9rzvnvbjqzbr8dlhxvfnh +4one84 +six3txbfhvhmkv19 +jnvjqfeight6eighteightfivel +8qshjffmdrrmmtl6one3 +7rxvqgnd3mfivefkrkvmfivenine +8vtxtqg44 +bbhbhkpv7mqzrl58twobkngmjznpmnszmthree +sevengmrtjdgqrpjxlseven36fouroneeight +five758eighteight4 +59kshsonesixfive +lkvtwone1zpkjnbjtjrqppqsksdz +onesbqtbsffgsixeightnineninexchm2 +9eightnqck2tx +zhbpbrxjd9 +659fourhdrxjeightlflseven5 +zjmmvhjbm243oneightgp +3hpfplfkhz9 +6twotwo +sixfourfoursix1tthree +xlfour5133bbhmbq +dhthree5threesix +pdtmsixfourtwo6rl +2three5ftfvfktqvmsixseven8ggjnzhzhm +59four1sczj6jqlsreight +vrrgrhnj1xgmcmd76two2oneightgqp +nine5ljscvrfbdnine4four54 +nine6bfqcdczp16 +3oneighth +bt8three +26jnllqrrxrhpbnkcj +tlcnb88onekcxcchxvzseven95rvsxmsh +bmj53seven9 +one947twosixeight +l1rqhcjqnmj8mhkgkpskeightz +fivepsfcqrgjtkthreez9cvgfhpdclgtwofv3 +3hmd7seven5 +drfftcgdvsixkgzspcftsfour86foureight +rqpvcb4mgdfjcsix1eight +nine3nine +1mgqq3six +5ninerldqnmdh4 +qvkxtthreevddpczxpcv6nine1seven +fivembc1xjzeightone434 +pfhzttgbpzr6two3231eight +1eight11two9onethreeeight +45 +zjrjsgtbfjthreefmkfsclrnjtwo8eight +4sevenxjzt8one +sncdbnbm356 +5nineheight6one +seven4tqthree +mkdhlmffqv9rcbldrzvtgltcone5oneeightpsnxzlprpm +4sixqgflnsfive +hgfphllv3three2two +tvtkg476 +knnkjxs1cgxoneseven91 +thzxgnnz27eightsixthreetwofour +tfzptldgnsfive3bqblfdnine +9tfscsfj33 +zhkfstzlddqbdks6fournine +hvvjjfournine8six4 +vhq9jsllg862rrrrxfhkn +7oneseveneightq5xfmtsix +3three7979 +9dcvdgkmthpzktwofour +nvvfivezxcgdbxslfshcshbvvkklp9 +qcfqfckd3bcbvmg4b +gttwonerchfrxhvsixljqxmhrpjb6ninesixonenine +zfbfgvkx6 +cctfqjseventxjnmjltwo9sixeight +eightjq9 +sevenflj7four +65three8trqptndveightfour +46fkbhhqzgthree7nine43xfxptdxp +moneightfourcqdvm5sixnine1 +gsbthree7 +tqdlh7seven +4seven4sixprjslbrvbsix +eightsixsix8pqchtpttrq7threenine8 +fivehcthreetwoseven4hllhvmleighteight +five79gmsvqvfour +fiveninej7seven +sixglnrtwoxvvc45 +fivetzkdhmbzbvxndxjhljgbd2 +nineeightllpslcxbdvvmrtwo4 +twoshzhlngsixnhftqp9twothree +5rkdc9eightseven62three +knrpvflpzjsix3jmftfqmqtlgjnltkfm +three62fnrtckmnkcvplvtb3k3 +xtbsm8six2six6 +four5sixfivetqeightwozt +7qxhbpvknqb5sevenkhpphnpfhsix +29kxbznzxtwo8 +1sixrmfxcfive9 +fourjzmnxfprpbznz32six2 +two5six1nlrtqrcxm +69eightone18 +fourthreev29sixthreeone +ninekpjbjm7683 +2ccnpk +3three3f +7fourthreenine +3seven5onefive +nfsssvfzfive9seveneightfour5sevenpstctrnkmj +2nlkgsix27c +lsr1 +vzlbfiveninetwovdrncmmnf3five +fblnvgx4sqspkgdkgninefhqrxnmgfourseven7 +z5fourcbnbkjzz99eightdbkmrcdhbcsix +jgvhjddq6vccsbrnonedvsjkrnbeight +85four7mfqnt8three +sevenfive95ktghsd +5ngr34kxqnmdvk +fourcdr469jvjd2onedqvjqjftz +8vkmsseven82 +pksixseven9vthrzfouroneightlvr +87rdnzmgpnvflnqsbvkjq +sixxtnponejkmvmn6 +gz5q9eight462nine +gsixthreehvktsix82 +455mcqgnj +five9zzthqcgvfive5ninepvzxxonecshsghbmpj +9five7four +one1sevenhmddjlninesevenfour +xnhbmdlvgj82fivedvz +52dnxsseven7rszgdxlhgj +threeseven34two +97hsrpcxz2shp8one +7twofour2jthnzc8 +cveight55eight +six1lglhzsnkdfivedpnlgcjtldtqmd +tsqmjxmhxncdpr1jmxmgx2fivelvjltzvhjhone +mrxtmfmrh3seventhree +fourtwohk7 +9eighth95pkp +289fcqzqhlzsfqrg +tfkqtzhrbvllmvvzggjlzzp28mhpfztxpqsthree +5eightsv349two +98five4five +fivesixthreejfivepbhdlvnkb6 +onefivedfgkdr8one +236five5sfmjdfive +sevenqg5 +two4eighthtvcxhxone +99fivecnsnflqp9six +fivefourdfjjpv85fourkcttlqdpksxqjzgbgk +four7cp1 +zpgd2px +tltlzcf3djmzqjr9five +2twoninezrfivecttvkjfmmlrckhnrb +onetwo1sevenddddpklfourdlvsixone +18924 +8m +1bblbkt4sixeight +3xfsthreeonepjjprmvlt +four8eightptvtcfour +eightsrfflfxbpvtlbzsdv7two +fiveninefive5xllzgscseveng +1eightfivedmvdgzfqjrqnhtsh2eight +6six8vqfrpkfmkq7pbjrl8d +6threelbldnpx +9four78one1four +vfivesix6 +2twonemg +sixzsxfsgqonesix7tvhplmf +threesix56five4 +dt78seven4vzlrzb9 +seven61pfvdnlcq13threenine +pzvdtfeightsix2four +six632sevenfivenhmhknkflkjrcfrts +three4seventhreenqpjmrr +two3jhjvjqlmls7eight5sevencrzbtxqp +7jdlgznine +lg2hfteight3 +8cttggeightsix54czlc2nine +hc3dkrvqf +eightks65ninesix +gttmtsl247 +9eightxnjjf4jbrdbtwoctwomllpfvx +5ninettpkf +hvbhhn7knbfk9rfsxrgmfqfzc473 +xpvmvtplxdm9jjhzmpgcddfour7 +3pnzsbbcb3fivecsqhllpkslfqsdv +sdlseven4six1eight3 +3hfssp1nine4ldtjhsix +twofour1mqkkvczdbr8five88eightwox +5fiveone2nine8 +8xvkdtbbdqlmtp6 +9hsksxfnr4lzs7bkhfsh4 +nineseven876ninejl +6b7eight +jmvpfjsjvjtwo78bmhnxg +4vgrzfsptpx6rdrnpbsmckvrglrlfive +threecrvzssmsnfourfive9jvtcqxbppfs +three18lbjdvqp +cntz6xp2 +ttwonejhmjctlz374seven18three8 +56sqh1fvfshgmxxl1 +qsbrnj1 +nine1nine61onethree +4fourbnz5 +8one8 +six9k +xj74four2xhxq2 +9sxvspcxrzgfourfiveseven9 +ninermnfknxbtwoonejds9 +five4hpr +pztthbxhfour8xrmvpgeightslhbngshrs8 +41sixsix8five +fourcrvxprsjlgglczq7rnmbtwopktrzthree +fivebdmqrtwop1 +sixnineninehfqmpzzc9 +8sptsqhpzxfccpfivenskklrsmcftwokhlqklznone +22ttpfbqfnckkdqmptlfdseven +9onefive2cnjlsd7 +ftsfmbskf37onetmnzgjpcqsrt5bjdeightwosgm +sevenjseven5rnseven6lsgdr3 +twoeightxdghlhhsjq65oneightz +rxnfndqlq6 +7rfvztgnh +zjmklxvsvzlfgpgrtjpdninefivenine9eight +six3cktxsix1vnbdlfc +sevenninencdninefour7 +6826 +22eight +88vsdcvlkniners41qlfive +seven9eightrxhsndgj1vq88five +jvpbvsevenfivesix285foureight +8seven4 +rslvvsixeightlpchthninem6 +bmfkmthree5kqndvprvfive +8r7hpxrzzxgmcsbnrnhr93 +692 +1zlpvhnfdbtg +7fivefiveone +xkfd2eightsevenfourtwonegr +9fivesixtwo +rschzfcgrtwotckrdhdtv6mtwo +6tdxlh +twofivej2srhpxhj +58scmtvn3mndnjnbqmsthree5sevenfour +sixmclmtrlone8bgbtg +jzrhmgvllh4nxphfssd73 +mbsevenfzbtjqjb5mlgmq +sz73ghmbqvlhgffdkrrk +vlkgfhcsqklnkqdmdeight5jfivekvnjlbeightkcfrcgc +pn3spmgcseighttwohzgmctfour +5four6nhvkvlbjfour1kmnxskdpd +865 +twoqknkgggtwoqrvxgvdz83eightghmnphhcsb +ninefiveeightfq9bszrhqztl7one +fourbrj2 +lnqnnqbnonenv66 +4xgmjzpbptnine1 +gnvnnfourccfshvbninek8ninekcnhcxkk +47krxlf +thsix6jzxxqls2kgxdflrdtxzsix +4bjdfgxmsjrfivepkpvklmdthreeone5 +hxktj8 +rntwone5 +one77n +rpcqn5 +zonecvvzpltlkvq19 +rcnxqvqzj9nineeight59trdfxbr +8eightthreeone +jbksthreetworszgrht7 +xvk4zfbclkpbeight +2nineninesixsixfive5 +3seven5 +1jjmffhtxskjmgc6vhvjk +4six1 +one6five94 +rfqtbxltrhrcnpf7lbd6 +56fiveninenqpfrv +3eightsix823eightonesix +threegntdfqltbncn92 +g9eightkbpdqqqbz +79sevensjsvgbbnjeight +6sevensixvth23two6 +gxc5bgqtbgknfourcbjeightone3 +five7two +3nsjnxsjqqqszc4 +8bnxdbqtpggfhkvbqbjkggkqgvrjntxf3mrvmptgptcftspk +sixlfsvljpjmdsplnjffmsevendll3 +btjkmdsscd566nine +8zdbhzj +rrkshvnsixknbxdfjhq4nineeightvkhqnr +xpfqfthreesixseven1 +tbvgsqcjtctdpvm36 +onenine1rdxxcjgkp +two1phslfour4cb +63tvv +eightfivehtzgmggpxjsevenmsix3 +782eighthgzfdnxqcvngd +nine8zkqrcv +pjmgbhsbq367six +9rlmcphtvr +three5ktjhxhhdsv75 +hkqbbdgrvbone7q7three1 +6sevenfxf +one8fvmnz +three1pmlrhnbg38xj14 +seven51seven9bfxzkzvjeight +tworjvtdpdvhztwo6zbbcmrszhthree +zhbxpkhvvdf9nrlvxsqhpvdtbvxhqseven +five56three3 +qrpgpblxrfpjhtq4onepzx +lqzmkbhrthreesrdtbgpfmg7 +2sthreeninektktttfive +32five1four +hvsh71 +qvvtbg35hvnsevenxzslzvjjdpcfh5three +ninesevenmcxthmqffv6vrctchjvnv2 +5eight5l +nineznnghfhjgqgclsv69s +3tpxxcqtn +voneightmzxd16h +1sevenfour39 +onevftpfhpttn8zbsonefourkjgvxbtkf +five4qjgsjrt +8nsxz9 +four7twosixsixthreefourfour +4fourtqbdskvvn +nine9onehgdtgfzr +3fiveeightseven +four92nine6xsptzhlvsdxg +5two78kmrbn923 +6zkjtprddlxppbrndhcpxgsscnineeight6 +tsmeightwo961eightoneonejpcmsxpstwo +3three45mfslth5fourrj +xjqxninelqvlcrfvqtndsevenfive9fourvdlhpt +three2kmkmcv9onethchqfgtjtqzr +ffive5x +613mm25four +ninehdqhjd4two61eightfive +kbnmjnfqkone65one3dfxtlseventhree +twoeightsixsixjv1fourthreetwo +1vgcbgsevengrzc +8threensspvzxvtwosmskq2 +mmqvhlhksm5threeqhdgcls65 +c4dllhmcq8pv +4fivenine775 +1sevenfivepfqzsnz +3xrfivetwo6kthreesixpdfgjbsk +onethreetzffmzdq24 +eight4seven6rnqznchsevenseven +hsklxtnzlcpknhsevenjjxvkzxvm79five +7bvnnlxpx1six +pgqkcpzx9ltrdvcv +8twormcqrdbxnhhhh6 +7lkhmssvbktwoseven +three7one7sixpntkrttkm +zbscnhfpqplrzsghjxbjcpjqbgfive9ninesseven +4fivemxpsvsrone1lmmxqqvkmvprxbtt +7sevensixtwofouronefivenqdcrprsk +81twotjkhqzdjs9sgzqbbgf2 +snfgfqchtfk34fivexnjfqqv +ksjrvrbr6two +kdvbgptwo4twohqshpjqdnseven8five +fhdnbzvmsrrndqtcstgtwo3f1dbmt6six +126 +kdbdgkgkzhbzdgseven524seven +bqllslqqfrdtvone9ninezbcxpzgzkdzcx +4ninefourthreeninengshmnfhvf5 +four55cbrhbcpscnnjqxs +rh7mqbvlfjjnhhlqgqpdffnj6 +93onenine +hklqshsc7eight4hbbrzqbmvfourkqlsmknine +sevenblqqsd63five2eight +threenine1kncghvqmgt +sixfht5psfxvt +one4cmxfiveseven +94ssfour6twojrvscgqzlrnzrbnvrdxtxtzn +gqfpxxslmkbjsl8threetwojdv +9lcvgsl +1nine6sevensix29qjpsix +9seven7lfsbtnzcbmlq3zqcfmckb +6v1nbsstmrzkseven4vfjfmtktpc +7vdnhzgrdgkqmmhcnmjtfive7dnfhmjxndbsnm +fkczmxzshtsevenszcfbsljzsqcplc124 +eightone582 +1gccxfjhgbc37fourxzdr9n4 +rczkvvonepph1nine833 +1hpbvtk +onep3nmmdmtrmj29 +txmlgzjtrddxl1nine29vcjnxjbqeight +2sixktlcqbngvgeighttwofive6vsmzlmfb5 +zlkrfour89threerhnlnd1 +xnbznine43dcvpplpqzv4threeonefive +fiveoneckrmlzmpn98two +dgcsix74sevenmflkcrtpb +fldxlgcqxbv8btdkmrdhsevenrbmzkgkznbninenine +qvxspxxmr9bsjeight +622chmv7sqztsssvp3 +8cxspjfnxtrgvpeightnine +qsninetwo8dpd9five +zzlbgqoneseveneight15 +fourtwo6qqrjqvhbvbdlsggckb8 +4sixmfkdcbjzv46 +tcxt5twoq +9jzvkxfourzjxxbbqmlmfs +1fpxhpjsgfnine6 +1ntnmbj5pz +five81hhxsnhfourninevnine +jpmjrdjrrm7three1 +one6fhblldjnbnlzjhhpkdjfkr72threetwo +6fiveeight7jb7lqkghcmrhvhj +eight8czbc689 +qqmqspdtwo4ntbkmbbvkqpfzrksgcktlznj +ninefiveseven88618 +qjxcchckrmtwoone326 +1gjcklxrnbtmfqnvlnkfgz13kkptcjqndr9nine +hchgvsbfour7fourlgjkcrthreeninekvvqhzrleight +nmgdxt1 +seven5four6667threeeight +one2kcsddzkl3 +nzdtjvxj739tbdvc7 +oneone5three +onefourxqxkjq5 +23bljlvpltnbcxmmgslrhksjdlbzhddrfourseventhree +3five68vpxkmrb +7crfeight +1ktvdhsmxq +6pkr7seven +sixpmrpqtndhxxjheight88fiveqzgsftgfvhbnjdjtktp +73two2eight4three57 +5foursix79625 +43fourtwo13mmctvsrljtvd +5ddrjxjhfhjbdgmmgsqzpnlt5lfktpkbthncvjntnns +threeqnpknxvnfthreeqdmfour1tq +8rqdkzdjvpngdhzr6kqpcreightn +zrmtrpl13foursevenonejmvthree +zghbcdcrdqjtqgvnine2sevensix3nhqk +xmtxjmllhsbn1mtxvvrjftwo +78btvheight +four5seven68pzllptfqmxh2 +onesevenlbsp6eightsixtwoninelpfl +fhnttk3sixnfqvhdqhnfgpglpbpltfqjvkkmz +69three76 +pxkh55 +vtqfklninemxgnzspgl8 +53three7 +fiveeighthfive89fivexdbpthree +5lcvlpgxjmsqzbffcvpxrhtvbbcp +lfnine89sevenone9 +8lsthlhtbpfour +1twofour7b +3ncrzdmzsqfbvgjpx +fivenhcvbntlcfthreemsktzr9two +qgxzqdnzztplvql5 +tkxeight4onexvzfg +hh4ninelznnln6 +six34bgbbffg +psgqgrbhsdvhgdxvbdqcxmstnhnqmhchjmbtsdll5qrhlngzzonetwoneg +2125seven9six +12four2scvrttnvhsfive7 +nine1fbtf +twonine4cjqln +68ninethreeone +vhcmrbxlttwo2 +xmnbbnlmnk7flhcqrl +tpjpbnl9gcbhtv +1z5cjc +meight65csmkfourpmcv79 +f6four1f +one95zhnineseven1 +4hmxmkvzmpzb2 +5eight2 +3tmfhdnjtr1b +6tvpsbbqr92five +prlhtzthtwo3mjrblrtrsfoneeight4fourtwo +841jhhfkhppprnine5 +cfkninexcgbqkzsixqpmvptt9 +nv3cccghqhr4 +eight4mgczjmmtqcrd +two1five +threecxvdqvrggljgjqn6fourthree +tdvpx7sevenone41fourfour +74two24jjsxgvzfqxtwonex +gvjcdrbntvlphtwosevenfivesix8seven1 +pjhgq7qcvrls +pplbxsvmqfjjvfhnn3 +1four9four +eightsevenqnhmkckdzcstkgbcprsg7one +37bfivehndskks1 +9five1pnmqbldqj5 +dpcvcmkrcgbdhnxrnfourbx88 +3zdqrvffhsnlhseven +5fourcmpdkjsevenninepksfpdkxpbonethreel +six9hseven1 +jfive637ffqdnjfjseven76 +3one6 +sixthree5 +7vctcdxsqhqvftqqt61 +fourtwo5xjznnjgeighteightwovss +one983sevensix7 +pxddhlhzgjqxq8 +5xjkpcrh9 +4cgeightcltbsrjtkjcqrkgjf86jmkh +smxnvtv8 +jjhxddmg5mqxqbgfivextlcpnvtwothreetwonerzk +jqlfcmpd4foureightfive +nine5ninetsfhmclvcb8dsix +hfbnlvhd76kmxf414pm +9hgjzbkpd +8471lqbnine +zqtwonethreekcz3seven2 +one7eight9gcqmsxdlsqdtqv7 +kjvnsmcctfivetwo7 +8fourthreethree7 +2eightcrq4twotwosixnvdrnkn +2zhlnthseven8one +1sixfive6three7shjqz +five7fourseven +fivebml9gjvtlfctwo +cgvvsl44five5ztlfdrc +7559tfhcdvkthgx +cnktjkjmcg46fiverxlxkmxvkmnklsfive +5lvlhsjkxssfour +sevenfourfour99seven8 +ktgfiveone76ghj +7zgzsevenftkdfour186 diff --git a/day1/in.test b/day1/in.test new file mode 100644 index 0000000..7bbc69a --- /dev/null +++ b/day1/in.test @@ -0,0 +1,4 @@ +1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet diff --git a/day1/in.test2 b/day1/in.test2 new file mode 100644 index 0000000..41aa89c --- /dev/null +++ b/day1/in.test2 @@ -0,0 +1,7 @@ +two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen diff --git a/day1/p1.c b/day1/p1.c new file mode 100644 index 0000000..77ff426 --- /dev/null +++ b/day1/p1.c @@ -0,0 +1,42 @@ +#define _GNU_SOURCE +#include +#include +#include +#include + +int main(int argc, char **argv) { + FILE *input; + char *line = NULL; + size_t line_length = 0; + + if (argc == 1 || argv[1][0] == '-') + input = stdin; + else if ((input = fopen(argv[1], "r")) == NULL) { + printf("Cannot open file %s\n", argv[1]); + return -1; + } + + int32_t calibration_value = 0; + + while (getline(&line, &line_length, input) != -1) { + int32_t current_calibration_value = -1; + int8_t last_digit = 0; + + for (size_t i = 0; i < line_length-1; ++i) { + if (line[i]>>4 == 0x3) { + if (current_calibration_value == -1) + current_calibration_value = (line[i]&0xf) * 10; + last_digit = line[i]&0xf; + } + } + + if (current_calibration_value != -1) + calibration_value += current_calibration_value + last_digit; + + memset(line, 0, line_length); + } + + printf("%d\n", calibration_value); + + return 0; +} \ No newline at end of file diff --git a/day1/p2.c b/day1/p2.c new file mode 100644 index 0000000..03951c4 --- /dev/null +++ b/day1/p2.c @@ -0,0 +1,103 @@ +#define _GNU_SOURCE +#include +#include +#include +#include + +int main(int argc, char **argv) { + FILE *input; + char *line = NULL; + size_t line_length = 0; + + if (argc == 1 || argv[1][0] == '-') + input = stdin; + else if ((input = fopen(argv[1], "r")) == NULL) { + printf("Cannot open file %s\n", argv[1]); + return -1; + } + + int32_t calibration_value = 0; + + while (getline(&line, &line_length, input) != -1) { + int32_t current_calibration_value = 0; + int8_t last_digit = 0; + + for (size_t i = 0; i < line_length-1; ++i) { + if (line[i]>>4 == 0x3) { + if (current_calibration_value == 0) + current_calibration_value = (line[i]&0xf) * 10; + last_digit = line[i]&0xf; + } else { + int8_t digit = 0; + switch (line[i]) { + case 'o': // 1 + if (i+2 <= line_length) + if (line[i+1] == 'n' && line[i+2] == 'e') { + digit = 1; + } + break; + case 't': // 2 3 + if (i+2 <= line_length) + if (line[i+1] == 'w' && line[i+2] == 'o') { + digit = 2; + break; + } + if (i+4 <= line_length) + if (line[i+1] == 'h' && line[i+2] == 'r' && line[i+3] == 'e' && line[i+4] == 'e') { + digit = 3; + } + break; + case 'f': // 4 5 + if (i+3 <= line_length) + if (line[i+1] == 'o' && line[i+2] == 'u' && line[i+3] == 'r') { + digit = 4; + break; + } + if (i+3 <= line_length) + if (line[i+1] == 'i' && line[i+2] == 'v' && line[i+3] == 'e') { + digit = 5; + } + break; + case 's': // 6 7 + if (i+2 <= line_length) + if (line[i+1] == 'i' && line[i+2] == 'x') { + digit = 6; + break; + } + if (i+4 <= line_length) + if (line[i+1] == 'e' && line[i+2] == 'v' && line[i+3] == 'e' && line[i+4] == 'n') { + digit = 7; + } + break; + case 'e': // 8 + if (i+4 <= line_length) + if (line[i+1] == 'i' && line[i+2] == 'g' && line[i+3] == 'h' && line[i+4] == 't') { + digit = 8; + } + break; + case 'n': // 9 + if (i+3 <= line_length) + if (line[i+1] == 'i' && line[i+2] == 'n' && line[i+3] == 'e') { + digit = 9; + } + break; + } + + if (digit != 0) { + if (current_calibration_value == 0) + current_calibration_value = digit * 10; + last_digit = digit; + } + } + } + + if (current_calibration_value != 0) + calibration_value += current_calibration_value + last_digit; + + memset(line, 0, line_length); + } + + printf("%d\n", calibration_value); + + return 0; +} \ No newline at end of file diff --git a/run b/run new file mode 100755 index 0000000..90637fe --- /dev/null +++ b/run @@ -0,0 +1,23 @@ +#!/usr/bin/sh + +DAY=1 +if [ -n "$1" ]; then + DAY=$1 +fi + +PART=1 +if [ -n "$2" ]; then + PART=$2 +fi + +INPUT=my +if [ -n "$3" ]; then + INPUT=$3 +fi + +mkdir -p bin + +set -e + +echo -n "Day $DAY part $PART with '$INPUT' input: " +bin/day${DAY}p$PART < day$DAY/in.$INPUT \ No newline at end of file diff --git a/test b/test new file mode 100755 index 0000000..70674e0 --- /dev/null +++ b/test @@ -0,0 +1,8 @@ +#!/usr/bin/sh + +test_case() { + [[ $(bin/day$1p$2 < day$1/in.$3) = "$4" ]] && { echo -ne "\e[32mpassed\e[0m"; } || { echo -ne "\e[31mfailed\e[0m"; } +} + +echo "Day $1 with test data part 1 $(test_case $1 1 "test" "142"), and part 2 $(test_case $1 2 "test2" "281")."; +echo "Day $1 with my data part 1 $(test_case $1 1 "my" "55621"), and part 2 $(test_case $1 2 "my" "53592")."; \ No newline at end of file