From 7369a9da52fd888c6ae704f396627e1fc2838475 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Fri, 1 Dec 2023 13:51:23 +0000 Subject: [PATCH 1/1] Done day 1 --- .gitignore | 42 ++ CHANGELOG.md | 5 + README.html | 159 +++++++ advent-of-code23.cabal | 105 +++++ advent01/Main.hs | 42 ++ app/Main.hs | 4 + data/advent01.txt | 1000 ++++++++++++++++++++++++++++++++++++++++ data/advent01a.txt | 7 + problems/day01.html | 146 ++++++ src/AoC.hs | 13 + 10 files changed, 1523 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 README.html create mode 100644 advent-of-code23.cabal create mode 100644 advent01/Main.hs create mode 100644 app/Main.hs create mode 100644 data/advent01.txt create mode 100644 data/advent01a.txt create mode 100644 problems/day01.html create mode 100644 src/AoC.hs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a0ee39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Extensionless files +* +!/**/ +!*.* + +# Haskell bits +dist +dist-* +cabal-dev +*.o +*.hi +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +cabal.project.local +.HTF/ + + +# IPython / IHaskell notebook checkpoints +.ipynb* + +# Sublime text +*.sublime-workspace + +# Logs +*.log + +# Profile exports +*.ps + +# KDE +.directory + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..665339a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for advent-of-code22 + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/README.html b/README.html new file mode 100644 index 0000000..9bad639 --- /dev/null +++ b/README.html @@ -0,0 +1,159 @@ + + + + + + + Advent of Code 2022 + + + + + +
+

Advent of Code 2022

+
+

Code to solve the Advent of Code puzzles. This year, I’m using the puzzles to develop my skills in Haskell. I’m writing up a commentary on these puzzles and my solutions on my blog.

+

Learn you a Haskell, Introduction to Haskell 98, and Hackage are good resources.

+

The Cabal user guide and How I Start: Haskell are good sources of using the tools.

+

Toolchain

+

Install Ghcup following the instructions, making sure to load the updated environment with

+
source /home/neil/.ghcup/env
+

and then set the default GHC to use with ghcup set ghc 9.0.1 .

+

Install Haskell Language Server for Sublime Text

+

Creating the repository and project

+

Create the repository as normal: create the project in Gitolite, clone it, and insert the .gitignore and README.md files.

+

There’s one package per day, with the code for each package in sub-directories of the root directory.

+

Create the basic cabal project.

+
cabal init
+

Modify the advent-of-code21.cabal file as needed, such as updating the Cabal version and writing the common stanzas.

+

Creating subsequent days

+

Each day lives in a separate directory, with code in the src directory.

+

Compile with

+
cabal build
+

or

+
cabal build advent01
+

Run with

+
cabal run advent01
+

If you want to pass in additional RTS parameters, do it like this:

+
cabal run advent01 -- +RTS -K0 -RTS
+

Run interactively with

+
cabal repl advent01
+

or

+
stack ghci advent01:exe:advent01
+

if the first form is ambiguous.

+

Profiling

+

To profile, use

+
cabal run advent01 --enable-profiling -- +RTS -N -p -s -hT
+

Or, you can simplify the RTS options by adding them to a new stanza in the cabal file:

+
executable advent01prof
+  import: common-extensions, build-directives
+  main-is: advent01/Main.hs
+  build-depends: text, containers, linear, array, pqueue, mtl, lens
+  ghc-options:         -O2 
+                       -Wall 
+                       -threaded 
+                       -rtsopts "-with-rtsopts=-N -p -s -hT"
+

then running

+
cabal run advent01prof --enable-profiling
+

Generate the profile graph with

+
hp2ps -M advent01.hp
+

Packages

+

Packages I used a lot:

+ +

There are somewhat decent tutorials on Megaparsec and Attoparsec.

+

Packages I didn’t use much, but need to remember:

+ +

Readme

+

Build this readme file wth

+
pandoc -s README.md > README.html
+

(Using the Modest style.)

+ + diff --git a/advent-of-code23.cabal b/advent-of-code23.cabal new file mode 100644 index 0000000..2ee4d05 --- /dev/null +++ b/advent-of-code23.cabal @@ -0,0 +1,105 @@ +cabal-version: 3.6 +name: advent-of-code23 +version: 0.1.0.0 + +-- A short (one-line) description of the package. +synopsis: Solutions for the Advent of Code 2023 + +-- A longer description of the package. +-- description: + +-- A URL where users can report bugs. +-- bug-reports: + +-- The license under which the package is released. +-- license: +author: Neil Smith +maintainer: NeilNjae@users.noreply.github.com + +-- A copyright notice. +-- copyright: +-- category: +extra-source-files: + CHANGELOG.md + README.md + +common common-extensions + default-extensions: AllowAmbiguousTypes + , ApplicativeDo + , BangPatterns + , BlockArguments + , DataKinds + , DeriveFoldable + , DeriveFunctor + , DeriveGeneric + , DeriveTraversable + -- , DuplicateRecordFields + , EmptyCase + , FlexibleContexts + , FlexibleInstances + , FunctionalDependencies + , GADTs + , GeneralizedNewtypeDeriving + , ImplicitParams + , KindSignatures + , LambdaCase + , MonadComprehensions + , MonoLocalBinds + , MultiParamTypeClasses + , MultiWayIf + , NamedFieldPuns + , NegativeLiterals + , NumDecimals + -- , NoFieldSelectors + -- , OverloadedLists + -- , OverloadedRecordDot + , OverloadedStrings + , PartialTypeSignatures + , PatternGuards + , PatternSynonyms + , PolyKinds + , RankNTypes + , RecordWildCards + , ScopedTypeVariables + , TemplateHaskell + -- , TransformListComp + , TupleSections + , TypeApplications + , TypeFamilies + , TypeInType + , TypeOperators + , ViewPatterns + +common build-directives + build-depends: base >=4.18 + default-language: Haskell2010 + hs-source-dirs: ., app, src + other-modules: AoC + ghc-options: -O2 + -Wall + -threaded + -rtsopts "-with-rtsopts=-N" + +executable advent-of-code23 + main-is: Main.hs + + -- Modules included in this executable, other than Main. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + -- other-extensions: + build-depends: base ^>=4.18 + hs-source-dirs: app, src + default-language: Haskell2010 + +library + import: common-extensions + build-depends: base >=4.18 + hs-source-dirs: ., app, src + exposed-modules: AoC + +executable advent01 + import: common-extensions, build-directives + main-is: advent01/Main.hs + build-depends: split + \ No newline at end of file diff --git a/advent01/Main.hs b/advent01/Main.hs new file mode 100644 index 0000000..9bdb587 --- /dev/null +++ b/advent01/Main.hs @@ -0,0 +1,42 @@ +-- Writeup at https://work.njae.me.uk/advent-of-code-2023-day-01/ + +import AoC +import Data.Char +import Data.List +import Data.List.Split + + +main :: IO () +main = + do dataFileName <- getDataFileName + cals <- readFile dataFileName + let calibrations = lines cals + print $ part1 calibrations + print $ part2 calibrations + +part1 :: [String] -> Int +-- part1 calibrations = sum $ fmap getCalibration calibrations +part1 = sum . (fmap getCalibration) + +part2 :: [String] -> Int +part2 calibrations = sum $ fmap (getCalibration . replaceNums) calibrations + +getCalibration :: String -> Int +getCalibration calibration = read [head digits, last digits] + where digits = filter isDigit calibration + +replaceNums :: String -> String +replaceNums [] = [] +replaceNums haystack + | "one" `isPrefixOf` haystack = '1' : remainder + | "two" `isPrefixOf` haystack = '2' : remainder + | "three" `isPrefixOf` haystack = '3' : remainder + | "four" `isPrefixOf` haystack = '4' : remainder + | "five" `isPrefixOf` haystack = '5' : remainder + | "six" `isPrefixOf` haystack = '6' : remainder + | "seven" `isPrefixOf` haystack = '7' : remainder + | "eight" `isPrefixOf` haystack = '8' : remainder + | "nine" `isPrefixOf` haystack = '9' : remainder + | otherwise = (head haystack) : remainder + where remainder = replaceNums $ tail haystack + diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..65ae4a0 --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = putStrLn "Hello, Haskell!" diff --git a/data/advent01.txt b/data/advent01.txt new file mode 100644 index 0000000..452d1cc --- /dev/null +++ b/data/advent01.txt @@ -0,0 +1,1000 @@ +3fiveone +eightnineseventwo1seven +9h1xcrcggtwo38 +nine4pvtl +seven7rsbqpgxtjzsgxssix +twofivethreepqgsvrszczrthree7 +44qcrkvr1two +zstrmphtxdvdpsnhpnq4threenbjznsb +bhgxhb41eight +qhstsbxsspsrfourmtvtnfhxlj699one +onekvhgkeighteight6two7ninelnfzbr +xsixz5six3gfqrzmpnjgskd6 +qfrpksmzzvfkddtfh6838 +mztttgnxdqt4 +8threesevenfourgbgteight5twonenjr +bpzkn2rbbjtdtlznl +glckqhjsbsznseight5dtnxnsix7 +2shd3ksrtmbs62vvdvhd +9ninemdkkqjzjfour9mzspzjgmlhfq +7twoqjbshcfxldnkc33one83 +zstxvfdthreeseven7mdfpgzgfourdfshplvqflfprt1 +9mndn31msfprm1kpk +tmczplnmrsevenhmhprtllcktpr8eight9 +49nine29917five +6qspssvm8 +7fourninefourcpfgpmxqjsjxmjfntwonine +3nxfjmzhseven22one +tzgnljxhs9nine1lvqgsix9four +eightthree9eightfourninexl6gsdhljppfb +9g +2xlcvqrxs2eightznzdghnlvcfour8xbzk +xgmfqvdbsn7sixnineseven5 +65zsghsnfbseven9 +7skmb5 +dbvjtf294threefournine +21hbtcfzbjhsbxlhd +27four +jlrthree9four8fourhqnsevenxqlmtsmzt +gjppzpvglfsvdmonercrsn4 +3zzxmhc +ldfgpzjmtcbj3jvsltltjv1eightzrdczhrzpcssrsrxbj +szblqqfgxhxkk3fourvqnpzf1onesixthree +vsb37three +8kxdcgmpb2sevenjdvc3eight7 +kgrsmfghvfivemhxnfiveqzzspmgmsvvghzd1fzcrkzdfsb +5mphlhx5dmcxxcpcxsrdzdninethree +hmqdkgvk4twoeight +2rjxxdcgtq5fivehzslfc +srqzfsvpfbnsvninetwothree6sixppsmfrtcrxxth +4fourtwocdxnzkbznnrf +4six419qpqfvfdpcrqvsjhgsfgrkpfmphseven +hxdcttl72seven +qkoneighttwoonesixeightfive2tzmrtpcthreefour +bnjqlftwobvsvjqptdp1two94twonej +eightninetwo278prrbvmcmf +seven79two +one9bx +cfpbdmjbcd27sixfour +16snbjgjzqxzplxkkclpxzdx +3scbbonenine5fivethreenine +21sixsix68oneninefour +6ninejmtrp4fivekxgdgj +6mhlddxbshqbseventhree3two6six +7four8smntchbmj71oneeight6 +six25four196one2 +2foursixftdbhbtd6 +fourfonekfsxdgvglvtrnrrjzmmkzxljm3 +3xckjzm +six9ssvkh1hdxcxmsptlxgdd8eight +2eightfourone2ninezslhqhdlcp2qxv +7oneclztx7xsxhrhhggfbhzdfgkdfvsqjskmdzj +fouronekkxqtrkptqz8 +klccbbvbjsix3fivenine +rjrxdxdz33nine +sevenninen5 +nineseveneightlcfrlftwoxlsmrjxnkk7zlzpbzm +rblvkfltqtbm18one7bvkzvvqrlbtf +gdcbszzf6sqldx +twoninethree23sixninebnzzjgqrlfktt +62ninetwo +fourfour44z8 +6qxdvmpkq +sixfivesixthree3x +pcqfxpvb1threefive77 +pncgzkppqqhmzmzjmzsevenxbsggc8 +fivexxdvpl32rdsix2seven +9blqpthpvfourfour69bprn +8vxsdfbdjmldkvtkbr4three +threefive8 +ck4p6 +two9bpeightldmrnzbt +4dpd +one7four6rcvtvfmzmnineq3 +4njtvkkstgmbjptcpdpzdfive +2tsl1sixgfbbpdhxgrfpt +947four5four3fivenine +fivelhtkgjhhzxfp3 +7one1three4sixmcrjlkzrj +9fourxtzqsjjmxfivehttj15 +2lqnfrgvdninedrdj +9rtxjbffmsbsqdrnjjdkb +twofour8 +1sixfourone +nine1xzpqkfhmzkbqtzh +bbh9fqrbt94onebdppqmtjlq +one8nnngz5 +vchszvlzpljt1pdv6tqsk6four +sevensix9qmjkrglh +5threenine7fkrtbcsevenjlxrkltp1 +ggrsfivetwothree687two +jbtdsixthreexxvjbft5 +1four2eightseven8one3eightwogrr +six6vtltzh65 +7bbxlhgdbrh9sph44sbboneoneightxcn +lptqrf9twofzbmbbkkmt +1zhxmsevenlnsxmdcpz5one +63one +one3ninepcnphxdzvhvmcv846 +nkn6eight21one +s1cnkm +sixone3 +sixbvvmreightonethreesixthree3five +bvbeight5sevensixchfrkjz +hkfkczqffjmndzseven7fiverklvhv9 +rsfccvtl9seven +fourczfive5threefive5qj3 +9fivexskp3 +tsrdgzcvftbvllhvcvzzthreetzzspvvjkrfgn9 +bv8twotwo9nh +lbksl3cpgzlxjgnrpqslbsknglctwothree +nine9eightqhcdzfcp2 +vckdtskc79threemblqcs3sixndlxfpq8 +1ggkrvbpsl9ssix6one8zh +679one9nzsktvfseighteightwotjm +threefive7gfzptnxbvvlzlxbteightglseightworsq +843trvvsxdkfspsixonethreeone +hsrqmrfvvzkczhphc8147xrrnzldnvr +m6six +oneccnxglxone29 +37jvhjvvlbv223mmnrthreesl +bpeight1 +twocd8 +4sevensix8twotwohhmzr2 +djpbjhrcfour5vbpkmsgnjckrkvt7 +sixnfrlbv8sixrqgmt4qmftxnrmx5 +sevenzvhhfourchckzrljhfivevjbxxh91six +eightckclzxbkqmkncvfdxfx84zeight1 +9stftdhkbs4 +qrpbdqzsjfj3seven21zktlblk +seven87 +lpms5 +pdgpscn74s4onelh8 +7ljbdfour1tnfive81 +3rjlmtdvbr +lnvjkkgjc5 +7vxlqgxk5lkfdnsdh3 +jlpgttbf35fourthreenine3cdfxbsdgslczvpjssm +eighttwoplpbcbkltwobvzccbhxndndmgxdf5 +eightoneeight4 +rkfx585 +9fourfour +7pxcnjslqgp98sixpkhvqjhjqgeightone +fiveeight1fivehvqrnzxqlkrcmd +sevenvgzkmhst8ninegcgzxkxr4dpdjsmone8 +fourgjfncfeightlptffqjhrltngg6 +sevenqkjdtxptzbtwo8seven8 +757ltrfkjzeight57 +1twofoursix2xcqkf +7ninetjngrkq7npldprkd +kqcgtnxvjv9 +nsvqdsqzthreeqtzzhpd6xcggbnkxfone5 +eightzkmbhtmpxxjlfqqvmvmbvgmbtpcbpz1 +six1tpvs2sixnctjmdlc +695one92sevenggrsc +stpr38onedftngldtx8lrsgfljrc +1vbzxfive4fivetwotwo7 +kdsjx2 +dntkrpshcmqpgskcgsgvq9 +6pskhmkpfive1nmkcvonemdfpqdtvdl +fvfndcnine7khthreehljzshdbkblgm +eight49rcbnkmdthreegqlgvksvxksqf7 +22xsix +twosevenfive72bccn8rbzkfczgssqcg +two9hclkszjmxonetlgjfive1 +dgpm6nhzkkqng +qrnkpxnn3lltxqxxjzxdkxhlkceight3eightthree +two5two4one61 +59ninesix +3nineninesevenfour +9cvsx1jzrxhrxshldtbbn9 +65four +three738 +cvj2sevenxrsdqhp +p255hztrqj92sevenjlpzm +qjsdgdjrxdsjdfx7one +6fivexm1qhxbgcvkvxb +fourxdnpqmjs3bqnzzphp1 +7nmrndvq7jnxnlsseven9twonelxb +four1sjnh5zkrrlxxj +hphshrj3cztfgm23two +1zgvfourninefivetwocllkr +1mgqmktstwo +5ndrsix5tdmfcjbgvff +4onefive9918eight +sevendbtcttvmcnljp3threethree1vmsggrpx +four5llnsvvcrcgd7sevenldffd +nine2five9fivemfour +2cpbhssgzfsrhjtq2onefmpdqfivehxvbzpfmg +spglsevenrtbrkpnrq6 +bbfqkt5nkfrzl99gxdlzzsb +6csshxkzkshsxnnineeighttwoclslvdkjkc +five9pcb2nine4two4b +brzrd5threendzpvs7ldkjxmpqqr +one4vdtwo +fourseven5493dvldshvz +1gkmnj +ninethree8 +vshbcvtvvf4eightonesix +7nine485eightrmxbrd +dctwofour3 +18ftwo +twotwo8rzdbgeightthree +sevenztlzzn38nine3jtnqjsnine6 +14qrvcspxmr4 +783sixxkkhrpqjrt5ninesjflktt1 +73five3 +nrtwonetlmkldqrcjqrdn6gptzdclninethreenine +8sixxqfl +sndlpvjr3 +hx5zzlqk1571three +zvl1 +1twotnqcmfqrnr33rrhghsdqddpmbzd +nine1threevcninetwosix7m +six2onesix1xqjzczdrl3 +15jkhgkfzseven26 +fntvfkhfzsfour7onesevenfour +sixone653 +hnvftxjthnmfive1sevendfnpkpffgj +rdktwone9fourkklk9rsseven +2fivefive4eight +vmfour34lpjzbr517nqkthkljv +hk9rqtwozr189 +fivefive3 +5one6four9twohsnjkcp3 +one77twoeighteightfive6twonek +vrxbxdgmtwo8tmglzjx +lp4ckhf +srh2 +hsbkzggsfgeight5qhblzgsppxbdlpvhvcpgkndzkjtmpggpdx +sixzvhnnzffnsevenfourpkxnvc7one +fourvgv19g6xhphkdt +fgvl8nine42 +four97five4lfcmzchtbmtvtvbr +3onesevenqtwo21jjpgtwo +four44fournine1 +twozhhvcxck6 +skpvglmddmxlsrt3961nine +8twoonetwofourtwokxrplnrvhmthree +7ktxhsjdml6twofive +zfdtjbrfive669bscgkpeightseven +zmghddqkseight5two63three45 +x4one +5one1pcv9kkninenine7 +b678two +x7 +97foursevenbhrxdpkv1 +rjkfdbteight8fivejrspls231 +six2skbfzvnlbvfour61seven8 +2mcqpccjfs5 +8tm +kr9pmdxkzjsg69fnkrrphlxqpsqjhzbznine +eightcqmdq8twozbbzfkxlhsmmv7 +xvgflfourkhn3ninebx9fivedzsmsnf +crrsnkfmvtwosmjk7 +8four8796 +nxqhdsczcgnvq5 +8five5two9three4 +6clffour2eight3zgzjnnmfsix +1drp4six2rtszhttwotwo +zkmlfive7 +245eightnine9142 +sixfive1 +xvnbjvfivezhzfpvnsthree5bvvfive5cxjfkszprp +3bbvmq +13 +946five +5twooneeightbhxfhpvjmlgtkccqgmqjnq +mlq7 +122fivetv4 +fiveseven833pszfqhbt +229oneninenine414 +knmvqkkh1cjbbjnjzrtpxdjznn9six +78nslms +vqrdsmtjtgfourninethreefivextgtwo5t +slnrndksnb95three8vrskzqzfthree6 +4twofhhqdghjssjkkcjlbjthree +2xsnjsfngdqpzfmltkrsk1hvhktwo52 +sevenxxmxmmngqmdx2lbthree +five823nine +dszvsjnzn7 +tmvlsfive5prd +six3nine +onerzskmfthree3sctlkhcqrdzc97 +eight34kfour2cdgnnkdff +dmone3three5hjndcbbonethree +63five5513pdgczone +6fivechs4vk +3zlqsxzqdnpseight5 +five6eight13eight +zjknbtptmdzfour3one2seventhree +sxshgxbcxs64dmtzplkqnfffkpz +rml4b65htpzcrlrbn39 +8tlpnvnrhjb57 +fivetwo1five +9nrrms247qcffourone +n6two2sevenvtfsxhsn +dxjtpsfjcssix2ninefour +qfldkljtbqc4five72fourjqbkbrh +3nine1 +jflrjzjzfour3four8threefouroneeight +fivefivesevenseveneight771lhpzhb +nrszb3eight1tbzmmps79 +8kkskdtwoeight78eightvbmv +4bccrqxmrvd1three +nine93fourjhspbgnthree364 +11q +three7fourthreeftbxtmmm +mznine6six1 +sevendzpcbqjfdk83twobgqfourmkzfzflnn1 +twocvbtssm72 +keightwo12 +fourzxcbncddhthreeqsccqgsf4crzszqdd3nvvjsix +jmh3ggvdp +12fiveninefoureight +3tvlmfpkgrdthree2phmllhczeightj9qq +sevendndrnfpfzmgvfqnkp8pcjlttzfour7 +dvtbsjreight1fkdlffive55bxzpsrnxtbfour +7threeseven +qrhzdlsb4five +bvdvjfqvtrtqntrrnqfpf87njtjgxzkgbcnine +z927 +one2eight +7dpszhz3pfnrrtrkxjn +8mfkvn +258lkpqdc3five733 +1nine1threefour +nnbfzxdmm828cdgvfive +threetwothreethreetjzskgfive4 +six893sevennine82 +3ss48phseventwo24 +xgbpshxnkvcppnninepjcztcsevenqbnjcjftpxxkpqp66 +8mlkbpdpftwonine4 +5three6six1seven +91onelrttnjrcqjtnrfivec +322one +sevenmfpxvntvkpqvpbnnbpr5seven18sixeighteightwok +jnthkgsrone6vnkdvkjznjnboneoneseven7 +five81472 +2onefive +nine9oneqfb7 +tcf2two2145eightsix +vdjhlrksdhcone17three9qoneightr +fiveone82228bgrr +5rfxlfbbjqninethreefour +eight641 +2pjmlgrrzvv +kpqsxmvhp4twohnlsone3eighttwones +35sixd9eighthm89 +8four5onethreeqmdmttvchslfvnqrbftthree +fivemmbfjmq1jlvzsix1hgkbr7bxcsc +eightgmjxseven5fivefiveslbfsqrjrnbhqzgr +xr18oneqjgsnjfzcsix4 +9threefivekclcmrnsix654 +onelnh6sqvzxeight9 +6vjjpmmxxknineone79 +cdsfmz97twoninetqhhtsljsixseven +8five6 +ninepkp3 +eightfour4fqtrlnzt +one4pttsvonexsj4 +fczlpseven261 +9six6nine5nb4fouroneightv +2snzvzxkbbpcvd +mvnqjkcmkhrvnsxt3hjkj2ninethreezzbbrsdone +zktwonemhqnxssxftwotsd1nhfmrxpffoureight7 +qfhlmpxhxpthreennlk7chk7zzmlqxmtlk6 +7dxhzpmtwog9 +kfkmpmzxhn6four87rcthd +bvplp656vtxxlqvmm6187 +811beight +39586547 +18twok +pfxsfxsvkjrb9 +38z9trcxdbfivedmhtdrfive +19bhddbmbkbg77 +four522 +7vshvtblzonefbfcfgsfive2 +mgtwoneonecthreefoureight37eightjqlxf +eightnine67gthszx9tzxczcpone1 +fourfourthree2fivejrfgkb6seventwo +4dnreightrv6ql3 +csfgqxjdvm22jjnr9 +42szlhdvbdstllzldtcblgtfive7gnctbrmvmn6 +ztwoneeightfourzzsck7seventwo +two78 +1hxqtdxjqflthreesrzzdbxmfnvk89three +rnprnnpbjq7fivetwoneqsh +hkpjjpbl3nineone6pcszznjft8d +gcbtzdtkhnbbjnftwo2four7nineseven +3foureightonesixrfqrjlp +qvftcskmxdvnsrzqfourfivethreenine99slncxvjrcn +six5sshpxtr88 +7twofour +four143 +vrxxmzfp8 +four9tg8bfonesix59 +three3onezsqdtkrceighthnstg6three +7seventwonine +fivetwofour9nine1two +twozfdvkjzbtwo6xrjgmfgsxv +1dqfcfjcbxxgxrksixnine4 +rfpgseven5ninezdmbx5 +622 +nine19fivetvm +eightthreelpj58qjlnhr +9fourjtczvxfourfivebmzds415 +3fivejbgzdsx +fcqdbxgjf86twofour +nine6oneone +onefour1 +onestc6eight3oneseventhreeone +seven2six +plbgd5nmppgfpbtphsxldrllpmnprm +1three14eightbvnzx83 +four95kkpjsttjf8one +mrkrgj5xtqvvzpmxn8nine +nineskg78nbrnonelsxfxkxlrc +qxnvkcx1one +9ztbs2grvsixsqt94 +sevenjhtd7 +qjb78nine29 +3oneonegjtcppfrjs633 +3clhz +1v398nine +mqlsevenlcnblh94 +5fiveseven +73rbhnnsixsix7ntssps9v +svjsgvdsrspmsxzkczseven11nine4 +onefjncqnsbsvqqm4478 +mfzfzjhc1zgbtt +six1sevenseventwokvbtwogvpstm +one56nine +8sxhbpfrxfsixl9lthreehr9 +44nine4threethreedbbp +seventhreedp66gnxvfnpzvdpqflnx2 +twotwofour37cmfzvxqjp5seven +1twonexlr +sixtwosix6seven7g +63zscqhtonebtcjfdjqc +fiveklbblk4eighttwonefdf +seven7one +zz361tmxqdpmgseven6 +5onethree6cgkfkdcmnine2blhxzqxjqk5 +threefour43dp +hcmjsszeightthree4tsnppskn78ggl +7gzqsthtmvszmjvcgseven +onethree6sevenonetcxsseven +3twobzbxc9onelxfkvgsnhteight +hnljcxrhxhjkhmhtffjrcqmeight7kcjmhjlvmgq4 +5nineseven6lkxzlbf +49jxmvnql8crs +qgq6eighttwo5one +1xclqfour8bgqsjknine +mrheightwogfglthreeeight6threeeighttwodfkjgp +26three6nfrxkhqlq93seven +3two4gjzmvvnrhdthreekrqhbfgssjghksix +sixone6sixfour7four +zbsvkkmhmcone677hmjsevenrqmng +mqzjpd5foursevengxmsbjhl +lmrpmthreelthree19tvbnbfqggnftwo +x3 +6zrhpdnxqpbfourltbvhlglvseven +3onesixeightsevenqjjclpcndtzgnzcv9 +fiveeightrm6 +cfqonesevenszbvlkdpfourninetwo6five +9lhlsbntzfourhvxfxgfjfivezcvqfshmldcmmhb +oneseven28pjmqkd +one5three284fhrbztwoseven +jmhj2rnf983bbzsmts2xf +one981eightr4 +tmtwo2zrjdd9five +4eightsixsix +q3rszpbkftqv +6zndd7 +7sixflqjpcgrh4281 +89ninehbfklckdglmcgvm2 +712gsfgtdvthree +nine5knlzninerspkdklnthree +dhjmgthfiveeight79threefive +87bn +4eightkbppvkx9sevenzqcfrqlbxmk45 +fourthreekvtvdrlgjrk2four7c +six6dlmmmvfkseventwoonesix +47rsjqzcqsnffourqdggnkpgsqjgprhrx2 +ptbtpthmkeightxtzjftbff6dqzdq7 +48sixcfngcjngjs3bszknmgzjthree +nmcdlgrrdrmrrbpfn1 +5q6crrhphbmqr8zdddmnseven8 +fxlkdnq6 +threeffvsrjdbtfk6trsgmkn +one3fourtwofcqsgcvvg +eight8onexvdtthree1pzfrllrjrtktzvnrp +hlnine3 +54three3zxbdtjrlzone +5qjnpjvnzpfive2two71rphp +njseven6four +bgpkmfcbl72 +9vmjgvhvfvd1 +ttbmt46two +mksvjgxsbdnlg8eighttwofourthreesfn +mtjm6twoseven46 +fivefourcktdqsdlvpdq1eightwolc +45twoneqs +sevenplrfqrhfivejqzrnv3 +9nine4threetwolk6sevenk +5qxpfourfqtg +34cpbblldjfqpltcntpzninetwo +7eightfivehczsxqhglmtpsxk8hkksbzr +69two9 +6seven33pggfive1 +sevenhkhrj2 +4phnnpxthjn8 +4vnnfqdssrfive8seven8ninedfhl +frhf15three4vvlgthree +4nine3 +57hlrhqmxxxbl +eightjhblpnjk786fivekrq +rj9twofour +lmszmtrhpthreezbdghgfour7sixtwofive +ninesixrlxxsskgjpqfdpzbthree5 +qbddmnpgskf1tpfive34 +fxmninejzl319twoeight4 +two7ckzsmvqfcbfourthree25 +xzhqltqmdfourqshqmlxpninecbrsclzftwotwo7three +one3zdppmxfroneighthb +eightsix8tmh7fivesixgbdttd3 +pnhkxlcsh35 +four45 +9sevenfivehxr4eightfour8 +rmvmqbclzr5bmsxdzxgptlhczgsh42eight +bpbbvbjrptfourqpkdfqkjcrrpone1b3 +2six6 +ninesixthreexshfvpb5 +3xhljmkxlr1clcqkmbdrmtxptgl +gfkhdhgv27ktc7foursevenseven2 +eight1eight4 +nine4vzdqjs8three9 +2lhmbfzonetwo9 +nlhkm83cslc5three9sevennine +thhllmnnpxsbtjvnrnhq8rbvhzfrxzqqqhccqlzfggseven +four6six8kqmjzk8 +gcrqzmbsh7seven6 +8five575four9six +four615 +41xzlprtjncrlzbcgvbmclsqrnbdone6 +sdphx53c +threefblfr1seven3 +xqh1one +qztslzlkheightsixkrpfourtwonine7one +nhqdsngrf8seven7dkbkfbdgdcjvnmdbzx9 +7qrmrsnhvfive4klcrkkbtwo +qpltxmjl3twosixrnvmlqvgrgmgninetwo +43lbsbgjkng1one +lzjqmlxnk452zrglhpbpvtwo +fourlmcprk36mthree +cssthvvxrgpks48glbxk +qpmkfxk4fourbmnbfzhgn2three +zxkntbdnm3fivethreesixmkgztvrfpkjgxljbm5tt +1vlhrcllfjtsgmqcvhcbcr98 +nine6dlkvtfjfnq3hbxxm +eight42 +mnrdpvdpklgkjnrz4 +1seven93ninesevenjqmeighteightwoz +seven8933five4seven +9lldhvdqdzvdgptsmf1eight +7fiveninezfourkrltflg +threeseven9 +7hjfzpltbjqbkx1two +1twoqghxlrpmfourfivefonermntbg +77eightjpgmmjst4 +9three8586nine6kb +three8ninetwothree2 +13xrhdzqsonesix43bph +foneight7 +29one +rth7cczktksv2 +frrpbtjjcdfccdl1three +one5six4 +ninehszc5svnhfrqm +threezfrmbgmjzg6 +9eight8one8fxlkdjhql +fivesmtkcsskrq7hxqbfkbqlninegnqddjrvxb +zfivehhknpdm7fngjpkbvone +7five8 +qkcxcpjzggzdxrfhlbsdbq17 +654mk +2mqtgbmsnhq4zv48jzdchccdpzhs +rpkfj1hkrztwosix4bktdfk +seven9bxjmvrbb +9threethreeeightppdkjzltclnq8sixnine +7seven92 +567onefour8bsgjtrvsxkjlsc +1dnbsjbdsrsscq3ninefour +vbpkpgssljgtxdfivethree6 +eightsevenrkkjszmxvxtwo9jpvzldd6 +one7523vgpvlkd +foureightonepeight4 +9fiveeightone +nine7one9 +g328dbspnkseven +threeclqhr97five +8onefourffhrmfkvctt +2pzftpmvzfive +433tvdzmcrdl +five42ckvlkgkjxh35sixd +nine6hs +99cmtdzjtpxk15c2 +tconexjkkh9 +sevensix5oneeight +twotwo4ncmpzpvvdrsxkpnpfkjseven +nine42 +7sevenxntxxdnfckbkdh7seven6eight +2foursevenzvdvhmzscd8gmlxxkqxd +5sevenrzntpronehfpbdcmffdscfvsqjcvnbtqzpph +threefoursix6ninegdpmtlsix +lxcflpcvgctxhm1nine2 +seven4one9mkkznineck8ptpc +seven4qtgqrcvfcfourzfdnx +md13xsdltxltqhninemjs +fourtxtscncgxvp3tqthreeseven +8zzvkkmzhr7sevenfive776 +91sgceightvgzjdkkkthree +mfmvgtck5gbjstzvmfvtmr +nine57one84sixmqt +threekslcvdzlhhq6dqtkp9two4 +2slmvrvz38 +foursix6qlqvzqbdzf2 +mftwone3eighthhcsgfvrrj +174bx2ninetwo8 +ninetwo7mzlcjkmj +37four2 +cjmlmtwovrvsbmeightthreethree3lkq9 +cscvfbgpjmonep8hmlnvrhvgsqrvcp +tmqkssbt79ninerfgh88 +qdsxzxcseight7 +eighteightnine8threecbcnfdtm41 +ljpcfour1368nine +hftwoneninesixxxmdtcfd8lbvqdjg +kjktdqqbfourdvkjlprhkzgfivetcddgds1 +qjeightwohvvdbqdnbknktv8six4four53 +6482cbb1 +sixcczlxcthree35lqn51 +rmnmjsthreehfxsjqlpkjxmdkg7three +94lhpqldseven +fctfxjvnine7 +sqnthxzkctfk98 +8xpknqzfkone +9threeonetwo +59d8twoshphfzlk +26vtseven6bsfkgxmjqnine +6nslcxpglfoursevenoneseven +sfvpkkvdkrfour31one8bqcrtwokhqp +29vrcx5four9 +43two +eightsixpcmhlk7nhpxhmnrmponesevenpkfgxmrfnq +svfjcqdtnmcrtjdgseveneightninetwocnbrrbcgmreight9 +25cxhtcxvgkjlbcshxrfour7rcnkzmm +onethree14gvjpp +sevennxlncmqpkvlhbts1mhpfxzqf8 +six6fivesix +3fiveone8one6six57 +tqgdrncxgpxpxz33 +vrdxxljfeightseven63b +onetwo56nineone9kkb +nvpqcnrgqrrnzqsqrh4four +67twobvxksevenztnhfpzkj9 +rxddljfhxhlbqqrllk3six +8twosevenone +onejxjpcnzljjdkbkmgvvrjrkgxgpqzdmpjzt4 +ftbssc2fgtmsrjbr +djxnine1seven6sixone +grqxsevengkkgv83fhspzflvfbqjrm +ctsj5svksdtwostmft8twonine +two9thpzhrcvdl4 +one2seven2plxkgkldxcpqconecfnppseightwovz +prleightwoggdqszvonefrqhh791vxxcfv +nine4seven6ninepbfoursix2 +fourthree8threett488 +six984three9r3xjnmvp +261 +twoonedrbbmvrm8fivejsix +6onethreethreeeightxpcchknine +two55oneone3three7five +three3threekgpsix +rqvfvm9ninesixninesix7pfsxcrx +4oneeightsixfive +2fourthreeqjppmfjfxnzfdhlr +9gctq3 +vtzcng2jhrhgsqhq +eightmmxz6ninenleight +sbzllxonemjfffkhltgpshkmlrjb7oneone +7fourfivefivefive3qjfdzclghxtc +fourfour9hmmlhhbxfour46twomzsgpkht +fiveqc45 +2bvseven54sixghpnhleights +2qlhvfive6ffpbhftfp6 +4sixone1sevengqqqjbzr +spq17sevenhjfkkjzdf +eightphqcjzdfzpttgxbsix1fvmnvqczr +9hxzczdhdl8oneqkqdlseveneighteight7 +gllbrsevenfour4vfcgth +lxdqx59mvzfjcsjl9 +three2eight3seven8rzsthree3 +two8seven64 +eight4dqqgeightseven +71threejdzzk +6fourgtcqnjkzjljksdqtbddpvxznvmprjtr6 +3fxkdgm +eighttwo3four6zg +6rxlnjpgkkstkbzj +74pcpzgndmtjgngonejfskscqfgm +dfssmbbxf873rhrbxnfzcp +bpqlnrtn5eightsixdschkk +lcrhcxvbrqhbz1one8 +46mrpfrtpnzdkshjgfxnrjbtntdnfive +tlgtzp86twofive +eightpmbdvzmdmpfivebphsv2pzxtcsrvtgnqnhvsbdf9twonehc +xqkbgbseven5 +bheightwotwojl1one8 +five7zsixgsmtvpxkkdrjtqtfjdjln +poneightbrndfh97kqtpgcstvnine6 +svhgqmjgfoureight7twodsmcnjh6mmncjvltp +79sixfourdlprglcm +five31 +ncnmdbvvhnpqxzkktjzbsqxb42 +twoone8mfxc +sixtwogxhhvcqpvzjmnltcdskdthree3nvdqeight +stwone15 +threethreeghzvvdkd7 +fivesevenr3nj +five6rmrccmczninelshone62 +8threet4nsrrkhg6bprcjtrpgclp +3twoseven5 +26twopqtvsks5 +ninemhgqvchgzgndlone938five +5twoprnvvvfcbninexxfrh2 +6fdpxffv4 +ninetwo5one6nqngsbqghbphngmone +kvqfvnxnine9552 +1lmht +6jvngqeightqnp925 +one53rqlbdzfive453xp +32gntcntdtcv +6qxdnhpvrcd5fivenpmqb +sevenninesevenfive9 +98svjcb1nine +777ctrsnjzlfbxdzbvckr +6three4onetwofour2five +27hdhhbv68sevennineclpdtb +mknzmjqsp5xd7vdmfkbcfpgst2 +39twotwo +d78jjxpgrgmpbthreefivezlbvgphnsd +mcxgg3one7eightrzbdqzvfnvxn +ncmfng86sevendqscgbmlrjnkvgqmzzfff1 +fivejlsdtbktwosix3 +npnxr6five947 +2prjccpmn3hfnxpqht8nine5four +hfqrqpzfkqllthttmb4kcvfgtmp +2fourfour +6pj9fivenmhdlsx +6csv7ninesevenlzgzninesixsthrlvsst +7one83 +7mlrfqmjq47gfgpqgkgmpq72 +six5pnslzjhthfour67kcvgsix +ninetwothree3 +vb91two4two +eightdqmnsxlhhkz44two +trzzone6tcvrsznine7kdctnine +nineninefdfnxsixnrq2ninezrn +bl79eight59 +jvjxkgjrbqdmnzk432sixmblqqmpn +two39hthree7 +tdlcjpj5jhslsgfcx +4two9jzdfzbbp +9six7gtbk15vqzhhsbtxgmcx +7vptsbpmq1 +59nsfbgxkvphnqvt +dmffndtn9 +gzfnfsrdmrgtrbbsfive586xhrc +cxvgfjjvbtlvkpsgsknine4jjgntjjzgfqrmlfbx4six +3tszbt1six3 +ptjjhztq9eightseven +zglcldrtwo5fqhvmfivesevenxvkxl9 +sevenonephscj3foursix2 +ninelgclbhv37 +fczvmgkzbm2jnzbgxhqmzoneqsrdj61 +1v8hpchzrvnzfbxninencjqdtqvgl +seven6threeone +five2sixrlfqftqzgks +6three1xzgnkrzl2krjtxr +zgkjvnkczstwolctzzlsevenone6bglzxscglsnjm +3kvxbzmpvrp +75vfz2 +vpnh25eight +cnsdklvrsix2one +kvlsjffgfltbkckcznmgrr8 +56foursix +pmhgkfonehjdslqbdc4eight9 +twodmmsk57nx +lfjvsz6fivekfivefivesdplsixpx +twofivethreeqdgf3eightthree +43sevenhnvsp +threeeightzh3threeqnncknpxgseven +4vbnmhgrmtsblrhrtoneljbbnvxmtvbfzssgone +5kvqfxmlkgcmlmgbfiveeight +55ztqqfzvmdppdpq1three3sixtwo +26bskpdjql +threehhgxmxdz1five94eight +52fourzcbcfknlvlrnvhbnldq +three49four8gshbnmxlc8vphklsvfmhnfss +sevend95 +fbkmpcone555oneightkc +5qddnptqdoneonezczvnsl +78ttssqjfournddr986 +three4five +jb6 +ht3hmrbxjsdvrsnlzvsqrj1rlcfggt5 +5bgxfoursevenrhtcqf2dpkvfmsmh2 +8rdsljbdggzseven4chgfppzmzkj +hfcjpnrzsixfivefour6 +seveneight5hldmqltxonecbtknbeight6 +6ninetztvlzdmgj2xzbtk +three988twodndrqvqpq +4threejkrpgtlhgg6five +4kgxgmprssixseven +spfpone16 +xcpqvrthreemrggrvghqcgbqtkknvvk5 +2three84bxtwo +gjmv82mgnqqgnzcgcd +3nine4seven +9twosnine +nxfmfour8bgcgdkvb +8three6one +bxvxksbbdn3knpdc6stfbxffjggfglc +sevenmfpxjgnpb743five6 +seven7sm +8qxbbcxjvppeightwot +fivetwotwo1seven8r +96eightnrbeight84 +gljg4fiveone +8nine6sevenmllmmchzjxb +3twosixdcgl +6xsfmfjjnz6vstfvhndhlklrsc73kljcseven +threefour1 +tqtlxckrrch5jone9 +9qjsntszxb +ninetwopqfnsrxrfstwod8one +6eight85 +four63vgjflnctzssfstjx113 +1vhshftmrbseventhreetwoeight +51bntvpdmxfznine5hbt +fivebpcntvnklxxseven9 +2xq +vjcbktqbxd55zhdxrhjqnr +bxqndkhjg1sixvjct4 +2two1three +kkconeight5eight9 +gz6two +dmctnkrmone7fourdfqcfone3 +9oneightcb +fiveqzjsvjqlsd99kpsixone +8fivehfphnvtdf +3six8jrrlnpj +1six53hpmgsfqfourxmfmdqds +eight7ljkrn3cntjv +7rkscrcchttwoggxktqdptwodpkcsgpbseven +eightthreeseven9threebdlskshg +18xpklsg +2sevenjlscgksv +rmr3784sevenbgqfhklhl +dbmtkvthree9mmqzfvmhpthreefivethreetwo +566sixeightone6fiveone +sixtwokf9 +lzgsrdmnl2xpps +zlbmfmxtvhvng1eight +1nine76ninegpc +8onesevenxqjqrxflrb1 +2dhthree6sixthree +4eight16 +2threenvllhnkqthreelhfnbp1gmkcgdf +5threeeightthreeeight +qjltlxkptr7threezplpxvqgrrn5 +ftkjg8onedxjcnmrsmf6foursctg5 +threenks5 +btseven2dlqjqpsnhxqmvqnjx +43four +64thknbt3three +jgghlcsxl4gtwo9gfdcgxfour +mvdkntknjf1stttccdntnrxhhdzgnrzznineseven +2nine4nine +4s6eight66616 +r4eightjfldjbqhcpxnhmsmzsjm +3smktnsbtjm27cpkzvnjxone +hvtccdslkb83xmlpktzbfournlklrqfxone +seven5twosix9 +6dcqcfvcrbs8pxphlrrlvqlmjqfrlfoursixseven +qntwofivezcpfknsvq51 +kdvszdf9tzkbhmthn +79dcrnqfrnine +dh8hrfvk2nine1fivefourseven +rphmhjjnthree1threekbpbjhfk2threeggzjsz +fhfive3vcflkznnpfive +sp19onesixtwo5 +eight2ninejc4fivedgffn +m5ffive +436 +khpvrkl27twotwo +7fnbzfdsqeight5fourone5one +eight92nine48fivecnhzhg9 +83mkhqxtdt +fivezvmqbczkgclsxfour3eightthreethree +sixsixxlmh6 +sixfive98 +fourttlpxqponetwokn8tvkmrk66 +1chfcvrmxbtwo4 +sevensix1rlcnmbhs4 +eightftbfczpt8cgcnnck +fourfivessnxfmlzzfiveseven24mfbfx +49lqkxcxtjs2jdsbkmrvfninesix56 +fknjdjqcnm66hrktq +1three24four6 +rpxtwone83 +5vnntgqnrpjh537ninebbkcs6 +three5mjmzhht57 +six4gfqcdbdhx96jvhktthree6 +sevendbssnxndrdxlbvssrt8dtrgcxxsixonehhstdr +1sixfrzgtwo27pf +6onevnnptcxhzgonethreetfxlsvxfmbqc +gmqnpqsix7three3one5tpklvdfzkbqftkhrj +rrslpzr1 +7ninedsvqtgntjdsqqmhgpjkqxkbpgmkxl +sevenxhpjppgxqqz9nxgctwo +7onefour +one6dsntwo +ghlgnsztmtsevenfour1bsctrtmp +onehtzmgbpkjcninefive7bmlnvfhsreightthree +2822 +3threerbtmxdngpq12oneeightone +threenine7z +9bvxxcsnzfive98 +djctwonefourlxshzxzmff313onesixkzxxhrrfour +sevensevengjbfbzmvlhlseven7bgdrreight +seven34p5zpmnn +r27threeqzx27gspmgncgth +threeeighttwoone1jqghpbbl +onefqlnr9bmsvjsb2gcl4 +threeqxjjjtqx4four2mbxfive +5one9qnrzfdsixone +three184eight +2hcnineseven1 +onejgnvdndtwoqpdxbnzhkg91sevenrfgv +hmgseven1fivek866 +seven4four1zpgc +dl8three5 +7two2 +hbglb9719 +1zsgbsmmgprkmgssvnrbv7 +5sixfourrfbbvmlrjfourl +three63sixseven5 +seven3eightthree318five +6brhdvjnz +onesevenfivefour5four413 +two5689seventhree9 +59nczhdqzdr +3vsxmbrfkljfxlkxm1x +6nm6k5three47 +451sixxkcncfqr +xsixonevns4seven3vlxpfcttwo +kl6onehlrmxgbfourfour8 +qvfclpxqfivethreeninesixl521 +33hpkbonepsnfp8nine2 +three41fivetzzfvmlsfive5two +9two6vgvxhnfjone +six68five8pbgrvl2six +sphsdpxfdtgvmmtwoone8eight +z726vlhseven +nine9ninesix6xmgbsgfmpgxkzgpzlxqnjsqhr +fourknflljrbrq63five +42onef6seven +39njjvzt7threetkccstz diff --git a/data/advent01a.txt b/data/advent01a.txt new file mode 100644 index 0000000..41aa89c --- /dev/null +++ b/data/advent01a.txt @@ -0,0 +1,7 @@ +two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen diff --git a/problems/day01.html b/problems/day01.html new file mode 100644 index 0000000..7d029bb --- /dev/null +++ b/problems/day01.html @@ -0,0 +1,146 @@ + + + + +Day 1 - Advent of Code 2023 + + + + + + +

Advent of Code

Neil Smith (AoC++) 2*

   0xffff&2023

+ + + +
+

--- Day 1: Trebuchet?! ---

Something is wrong with global snow production, and you've been selected to take a look. The Elves have even given you a map; on it, they've used stars to mark the top fifty locations that are likely to be having problems.

+

You've been doing this long enough to know that to restore snow operations, you need to check all fifty stars by December 25th.

+

Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!

+

You try to ask why they can't just use a weather machine ("not powerful enough") and where they're even sending you ("the sky") and why your map looks mostly blank ("you sure ask a lot of questions") and hang on did you just say the sky ("of course, where do you think snow comes from") when you realize that the Elves are already loading you into a trebuchet ("please hold still, we need to strap you in").

+

As they're making the final adjustments, they discover that their calibration document (your puzzle input) has been amended by a very young Elf who was apparently just excited to show off her art skills. Consequently, the Elves are having trouble reading the values on the document.

+

The newly-improved calibration document consists of lines of text; each line originally contained a specific calibration value that the Elves now need to recover. On each line, the calibration value can be found by combining the first digit and the last digit (in that order) to form a single two-digit number.

+

For example:

+
1abc2
+pqr3stu8vwx
+a1b2c3d4e5f
+treb7uchet
+
+

In this example, the calibration values of these four lines are 12, 38, 15, and 77. Adding these together produces 142.

+

Consider your entire calibration document. What is the sum of all of the calibration values?

+
+

Your puzzle answer was 54968.

--- Part Two ---

Your calculation isn't quite right. It looks like some of the digits are actually spelled out with letters: one, two, three, four, five, six, seven, eight, and nine also count as valid "digits".

+

Equipped with this new information, you now need to find the real first and last digit on each line. For example:

+
two1nine
+eightwothree
+abcone2threexyz
+xtwone3four
+4nineeightseven2
+zoneight234
+7pqrstsixteen
+
+

In this example, the calibration values are 29, 83, 13, 24, 42, 14, and 76. Adding these together produces 281.

+

What is the sum of all of the calibration values?

+
+

Your puzzle answer was 54094.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your Advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also this puzzle.

+
+ + + + + + \ No newline at end of file diff --git a/src/AoC.hs b/src/AoC.hs new file mode 100644 index 0000000..764f2cc --- /dev/null +++ b/src/AoC.hs @@ -0,0 +1,13 @@ +module AoC ( getDataFileName ) where + +import System.Environment + +getDataFileName :: IO String +getDataFileName = + do args <- getArgs + progName <- getProgName + let baseDataName = if null args + then progName + else head args + let dataFileName = "data/" ++ baseDataName ++ ".txt" + return dataFileName -- 2.34.1