Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Day 1: Trebuchet?!

day-01.livemd

Day 1: Trebuchet?!

Mix.install([
  {:smaoc, git: "https://github.com/nettinho/smaoc"}
])

Part 1

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?

Part 2

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?

Solution

defmodule Smaoc.Solution do
  @numbers ~w(one two three four five six seven eight nine)
           |> Enum.with_index(1)
           |> Enum.into(%{})

  def solve(:part1, input) do
    input
    |> parse_lines()
    |> Enum.map(&parse_digits/1)
    |> Enum.sum()
  end

  def solve(:part2, input) do
    input
    |> parse_lines()
    |> Enum.map(&replace_words/1)
    |> Enum.map(&parse_digits/1)
    |> Enum.sum()
  end

  defp parse_lines(input) do
    input |> String.split("\n") |> Enum.reject(&(&1 == ""))
  end

  defp parse_digits(line) do
    matches = Regex.scan(~r/\d/, line) |> List.flatten()
    [first | _] = matches
    [last | _] = Enum.reverse(matches)
    (first <> last) |> String.to_integer()
  end

  defp replace_words(line) do
    words = @numbers |> Map.keys()

    Enum.reduce(words, line, fn word, line ->
      String.replace(line, word, fn match ->
        number = Map.get(@numbers, match)
        "#{match}#{number}#{match}"
      end)
    end)
  end
end

year = "2023"
day = "1"
run_config = ["puzzle", "part1", "part2"]

inputs = %{
  "puzzle" =>
    "51591twosix4dhsxvgghxq\n425nine\nllvmhjtr8nbbhrfone\nlpbjvpbtdfvtxtdvkpjs7qrvddkzmjtlqtg\n3sixnineseven\nrfmsqbkms7three\n33291six\noneonevstpxxrjpnine7six\n75sevennine14mzqljsjfbb7two\nthree6two9jckvk\nzprj8394threehczfkncntk\nmkqtlrzmzfsix2ccqsnnxtwo4sevenxp9\ntdszrfzspthree2ttzseven5seven\ntwo3fiveckrsjr\nfour14three7\n4fdkcclmxmxsevenfiver\n5sjnnfivefourzxxfpfivenine7five\n77sixfive\ntwofivecrkvmpcpvzddvzcmjhjlthree8fcrrninefive\nfivetwo562five\n2ninekvdbfnmjmd6ninentpktmgseven92\n2twonine\n5fivesprm4ndqzbqnjqx\n7jfq9\n1hgnkmx91\n2jcrmhfvntc3lqnine4five4\nzvqmpjrpninejhqrnineggghcrjfd3onefive\n11three64qjjhqdnonetwo\nrmvzjnbonetwo6\neightfive698threenine9\n8eighttrfngsklrkfivefourninefourqhclfcp\n1z\nfivegfslvcvtvs4\nsfq1twosevendbjq2nine4rzmdpmgcx\nseven816one8jmcqqhfnthree\ntwor4325rsl5\nfour2vqhninexqqhlfhfouronejks1\n7hjmmxhdnine8\n1eight3hqgshtb147\nfour6sixeightone\ntwomvkjxbqxzhnnmjxstkgfhzzdsc1fivefivesix\n3slhhsfnkhhlxtvqfrhvdzzkvlzcnlxgd4ninechp\nmeightseven8onegghfsfeight84\nkmxckzqdfeightsqfivefivetfg77\ndc8\nmktwonecvqsxhqrjfninethreethreedkllgfxrxrffzvdbqdj2c3\n8shsxjmqmb3kpvj485nd\nrbdlrxsmjvnkttnpfour6twoseven\nbkt1seven\nthreehkjhm9\nthreeeight8sevennine7nlx\njmvj4ctqpccsixseven\n4fourmtwoxcsvlvlhctdpxns\neight7three4729eightbslrgrhs\n26seven1\n7ffseven\n9rsgmlgcsevenxkmsd17three\nsnzn6htcqxqj7bf\nppr7six73znmtmgrzrp9\n61mj7dvddfseveneight\nthreevfive3fourseven3\nxznsxcxsbggvctqqb82two\nfive4none\nfoursevenrl12threegpbvdsspkrfour\n9sevensixthreerftbxgthree\n6fph\n996three\n64pkndfphqrglbgcpseven\n72749twoeightcpqfzqcrns\nxnzzhvssixtrlfftrjr5two9threenine\nfour8hzkkrpb71glpqsnkvcb\nsixsix1\n9lfdtwo4sevenjhv911\nchxjljdh8jztwo61three\ntwothree11\nhft2dmntjgzg1\nrtfckbnqxfdldgttbltdr33kqhxhkeight4\nninefourseven4nine5\n25fsmkbsevenpzhgdhnxnbsix3\nbd1frglljngg8one1\n34six\n96cpcmztffqdrfrfslfour4lpnbmrfm\npsxrlseven2zmkvrhckqcxdl91\nninexkfjcjkjb8three4xeighttqsrgbmfdt\n2threesixeight1\nggxzf3gkdvsqxggltxdhdbhm5\nsixtwo89six\neightnine3\nthreemdrhqpone6\nsncpmhtwozsfpcpxgq9three\nrtwone37three7xhzlckfclbltdkrgqbcrhpqzg\n68sixbgsz35\nkdeightwo69\nfour7bfq3four\nsixone3fivedgmrrvjqrr7three7seven\nsixthree6\nonethree3onevdtlkrfour4\neight4seven5cszgblfseven\ntwo8ddmjtg\nfivejnvrdmghnvrmrjeightnnxpv8\n2threezvklqkpml\ntwo76cdfrmfckbjc\nzqxpg42sixeightfour76\n3eightvqpxzsn2bnbkrfb49\neight85five\nsixngs8xjseight4\n296pfsgnlpbmngzlrrldznmrj1mjgvtxkr\nsix4bvrdgxh\n34eight56eightsixhphnbgscfb\ntwo4twosixthreeggfdzlbkxxqmtxtczdfj\nfour4tqrjxxcrztwoeight\none73zpfhjvjh2\n7eight35phcfcdzhhpzn49eight\nzqcmlcqfneightsixrpmmhcrssk6dclcpmhzqhrbcnkxjdfjvrf\n1threegkhpq7nfrksvm69nxpvgvthfzoneighttc\ngtjsevensixsixb9\nnine73nine\ncbhsddcmzmdv2bnnffour\n85hhqkqmv\nsix2jfxfgpg9\nfiveeightskrn1\nkhvcf3five8qj5\nsevenfive7ptb\ntscc9psz3gtnsnksn\nxzlh7zfivefivejgr\none4nine8three3\n2kjkbbvftktkvpbp8gkcnrrkr6r\n565three718five\ntwojjgcfz3fiveoneftvnldxdhr2\n13three\nphbvxsnnineksttklfljm85\ntvzpbgzhmbnine1eightbpjtkflllg\n7five3\n2623four\nnvfchhrbcone1nine\nmjv5vtmlmsfcfmt65five1\n7one2\n4six4\ndlbzctlxpjxxqk96pmdgdfblbfjnsxjmkoneqgeight\nseven4nzvxldvzvjpzlzxb4eightnine6\n2vzblzhrxnc8qtgvxxzgkeightblqfftjtnxrbpvlsgvd\nthfdzxfqcthqfcnrt2\nqxfpbbnfczfourh4twodjrhp\n4m2fivelklgfgr6three\n4tsbs74\none6twomzfncms2lrgzgsspkjmcgqxp\nsix5fourgzrhbvdnzzllh\n9seventwothree8sevenfive4two\n7eightdprzmjvsevenfourfiveeight\ntwosjzhsb29lqzkjbtshp5\n8four6two\nbklkfctjb84one\nsevensevenfive7seven6\nvklhzsjz5fiveeight5\nfourmlthreecjspnchzrthree8tb\n7gsfvptnpcl2n82\n58mdllbtjkkzcmdgzbeightbzqmfour\n2vtlzkzlsfive92vbpnq\njbcgqvr28ksbphtfourfourfksnxjhtb\n21ljfcmgtmdqfive\nthreejhhstcxfive64sixeightthree\n7tqpqngnrmnnxt3pjbcqjmktvj\nfmqqc9twoone15four\n5six13dnkxtqrxrh\n8xxpnpfivethreeh5ktnpctlqrgtl\n9hgmlnzsbmbsbjbg9\n8mnlsqkpqp18jkftxzfcklsgkvjr4threergdbrrzbb\neightglhhjsfl819lkzlxjvcshdtjhxvjs8\ngshmsmzfbcrhvnfnpppmmfmngcv2snrponeqgxvtx\n9sprkdkk3cpjzlzphfdbhczbpssix\nnine8954five\noneonettsixckhgprszjckhx2\nseveneightgnhzhm9pkthree3three\n5mjkpk\nsevenfour832five\nfivellhglxm2twoneq\nfqtfqdgeight2lfklmhrnfive\nflqdfkmlfthdvzncvbfour7gq\n793\nfourninetwojrfp4three5three5\nsnnnjlhcnine84eightjthbkgtslhp4skglpzhz\nmnxfgpg862ninefive26\nbmdtbfjonegprzlxqlkb4mcscbqnv\nnine9fourfourfive1fivethree2\neightfqrqz8\nfourpkd1bpxczlzthreecptvjlgzfmtqnr\n25onejrksrlccgrqtkcsmzccnine\n5nine26three88\n25four299fourfour\nhlrbll8vnhjlfjrkd\nffourthreefourkgjbsnbc6\neight8mpqpsgxthreegmxrhqkqbhgstcz\nthree82five1\n4dxvzg29fourdsh\nffgdlggchpcq7four34lfive\nseveneight9eightnpjmh9eightfive\nbnjrnsdfjg6\n76five\nfive4nine6six\nq339eightkhnjsixttvqzlbchleight\nkoneightonenine2nftlzxnkbctmjvzk98\n511\n4cghqsix3bqr\n958three\nseven2vmrkjqgrlb5\n9three6one5jdrnlfour6nine\nfour2xdrqqsktone\n1sevendxkhzglzxgcmonesixrplhlplhnone\n6threefourhshvnszlqrzb\n7hctfsqf2jzjkxbljg\nsevencxncnc68\n49lfdkv2zbhddmbfive\nsevenfdsmsmmgzv29two6rpxsgpdsjxljcthree\nhgfqhdfb4mninesevenzngfljcvpvvkmghqxoneseven\ngtlqcggrp6lzjfive3rtrqvszcrsevennine\nqvhztzsfddxbbxsr88\nnine5kfnninelknrbf5bjrrthv\npfnmdzksjcjcbvlvgcbheight47\nsixfour8\ncdbxkcqseven1\nonefive65mdbrnlg\nvlcxxcxhfkjhm6two5\nbfpnhlzq3tgcmhd4\n6three69eightgmxsseven\nthree1six\nfourgqqgvltwofkxzmcfdmz4\n24four68nxs84spjnpfsdv\nm1threesvlhmgsbn\nthree7jcvclg84sixfjvvtkfk7\nhznlsixjqnlvpmninejrvfpplbm5\nmgfrn6\nxb9469\n48713fivefour6\nsevenfiverzlhdzr59lbtvltccgbstzxksb\nrxkppsh771\ndldhcgdvtwosix3\none4phkrftwo\nrrdrpfddtphv88jldqht\nvgcpcmrj6\n9zdqnzlthreelxzmlhsgdc1pddz\n669onesix\n5eighthlbhzlpms7qvbftcrone\n8mttfjqjnsf528hzvljcx\neight9tseven25csfeight1\n7threethreetcdxnhnnftwosevennine\n54tsrjthq831sixcmxzqg\n61eight9kb5\nqlxmg4zhcpfxvrhlgjlcbxvxsix\n95two\nfour75eight\n6fbrnsflmxstwo\n25\neightcdl979gxzv97eightwogdv\neightgbx85sevenseven\n3rfvzeightsjcctzxvtcrsix\nfivevqgm14\ndbfkfnfbckncvseven83drnkzt1\n11ninesevenxlxfr\n4ptvstqt7fivebznine\n5qmcnfour9\nfour5mndpqsmxninethree56ctnlcpbtzmthree\nfour2bqnbcbninemccbzhrfourbgrccrsznskjn\nrjdfqd24seveneightwom\n9ztmbftvvzlqlr4\nqprftkd3vkfhtwofour33five\nfourdtmjbtvvdxdhj5\njpttch9\n9jkngffbxhg\none79twoonesix\n2eight528nine2\npsncczvbeight3\n4seven7nlgrlzsqjsdb51\nfive98lqc8\nnine377rcgvvhdghrg5scmff1\n8fvcxpr6kx5cpcrjdpnjcsj\nltlbphmcc7six2\n4threek\n8hzmfhrnvt\ntbmzgpgkkxc89z4sqpd\nfivefourdjpdgfournine37eightzqbpgcnfrq\nsqh6llxn9z\nfive1sixrqqclkhx334sixone\n289\nnqcspsixone822five\nbq19\nmxdqptgg99982vpthreesgdgsf\nvp334fourhdtjvlgtwo9seven\n3five157sixgzgxxfive2\ndvmtwone3sixfivetwo6ninezpjv\n9trtrdkldqj429hsrtd8\n6three3sxsbbhpgsix1\n3gccsixcghh\nsix4nnbg\nppvljnh5\nsevenmghppptnrtrzh7\n4sevenszkgbpldhklrtclm\n9qjsxmrmdm\ntwoskbhlqhnkmgzkpvtft9five2qrkeight\n1v\n988fkxgkbonerglfsknxr5eight6\nxkdklvjbhv977lvlnmrj3gnfjrnttm\n1fourthreesevensevenxfdmtdone\nfourmg4xtvjbfmqkhtbslq1onehmtrtvsslrjdfncr\ntwosgdlxsixfive1\nbscpkcfp8mhpvzn7threefqgcpfpmftsrmktwo\nsixeight4vthcxd48two\n1ninehclngfzbktvpjone\none2sixmzxdqxvg4oneoneztbmplctc\n5tkhrmfrvonetwo\nlfgveightnqdmrv9six\nzzgmcr1jgzjjljhqmtnbrnbt\none3vfour7eight\nfourseven3ninenine5four\n92kpdtggsb\nonecsfdhsn3gqmtfhc\nbhflvgdfkhprqqdgs6one\n1five93pmrhdvmgp7onesix\n56mgkt\nrksixfourfourthreefive3fdrbtgmdt2\n8one7\nrgvccbsrphxkmdgjkrjjztdzzmkgqbcdkseven69\nthree4eightsixjgbnthfxvltwosevenxjkd\n5cffmxhdbtgtlffdb\n8fivetwoneb\n5trtgsgkvplfvqccknine\ntwo4gjjmptwo\ntwo845lltssr6\nsix8xngnhbctl\nnhbxglqfjrhmhneightqmvlnqtwo53\n7nsr\none2seven\n8eight2jphsz9\n9fivebv7kmxqtdvxq\nninec4four\nvrtczjzbzg8bgf\npvhnfhvsixbppv4oneshhqp8jprm\ntnxqmfive1khnmb\nonefivechd69nine8\nsxeightwoeightkpjxbkrvtbllbxfshseven4threemkbx7\ntwofgcfp7ddjqvhrbvmkjdsltfps9bttz6\nsixninezpsbrvhvlz4\nfour6sbtdldjcjrn7\n79drd742\nmmccvnldbhxcfnpxrftqc1sixlncsqs\njjdpbsm2\n9fnhthreefourtftrmqhkmxrpnnhbxvk\nfive168sixs4\n65fourkpzbhhgsghxvhlvlftfmck62\n8fivesixsvmzjhdmdqsixntzrckdk\ngfzjxptdqnineonepqqsldlvjrg5pdgthrslpfcfive\n38mmkcseven2four\nvghjzfchxsqq8fivefourone1\ntttjzcm3\njpn764tsmrfvtjp7four\nonelhbhkmf7\n5ssfzvfrrvgleight71\n52lkxkxdjch5\n3eighttffhffht4\n832\n2gbhzrgchz\nthreessdmstrhchfq73ftcfbrtrvf\n8xqs9scc\nxglmdxq24two28kcckrsqpzone\n16mkcl\nldhmz3\nxzvttst5\ndrkkc3\n8zhbplhvcr4\none1xzbrkd59\nxzzbsnktjhjltsfrrrz3four\n8vlfgxgzsnfljbnnmlpz5nine3three\n99onehzdqm\n5zdtrvccn\n75sixsixkxldjnxslnvggnvvjbzcrqveight\n9sixztkk\nthree9sevenone\nzxsgxfxpkpp45\n9hkshgthreekkvrplztccvb\nsixbvdxrhrc16\n1jbjbqhnqgg5shmgfm9seven99fvpnrrpks\nsixstsxgbmcx12qhhdr\n9trfxqzkdstwo2dzone5three\none3drbrbtsevenonekmfdlffive\nnsnchfkxttwo2zgpbvkvktwofour\ncnzgzdvfm9\n8fst5jsgmxhbgklninebkkrs577\nxskvpkzcx2twoninebslrbdmqseven\nqlbpjqmptkseven9lqmcdvjcxqsix4\neight7six2\n33h8rxmtlctrz67dz\n3rmkrn83seven4bxthree\nmmznine55\n1onefour\ntwo4fivenine\nfivesevenpp2onexcxjvllseight\nonehtfzdtjxskmzsbc4sixfourz\nmfkttfxqvtdqdrl93\n567\nqqpnrfninetwo55eight\n4qqmlrfbfrvpxvphjpbc\nnltblqfourbxxrrgvgkcbb5hzzgfour5dmdxl\nthree2526ngfzssixsixseven\n1tffj2fcddnfxrzx34\n59jd\nsevenr8sevenvxltmxcssttwo9\nsvklhbtwoxbbmk6ninekptrln7sixjqbjgxdhzr\nkrbmcxpnxfrn4\npnkfournjgpggxzjd97two\ncplfrzbgbleight2z7six\nninep8xxxnine\nxqlrnzlz92ninehblgkztwonerc\n1nine7\none8three361two98\nnine367qqslvgcxftwo\n3fournine3twofkcdmx6\n1b2ninethree\n6one4sevencnlsqzzmcxkxfnqjone9csmkx\noneeightgh44eight66\n6x527threethreerggpfcfqlf\neight1tnine7gjvtpvmqb1seven6\nsix45six7fourmnhbskfthree4\nltf4\n3hgqgdsmnsnine\nhjqneight5threeeight\nonekxbrlhkxgxbmbn6eightfourltspzkqdnone\nllfphldmghqrcnineeightonefive9vldfskjbhl1\nsixpjf5gjkdqkvvqhj\n2five685kvh17four\npgslffcdvsix7oneightcs\nlznbhzonefivezgj45crzfl\ntwosjggnvbxcmtwo8four5\nfourhtstxbkcz6fclrvgfrgbv\nnine4ninefourfdkdmjvlvzgsnjsfseven\nthree318lmzcfive57\n5pmcnc\n861\nqbbhpjsg5r2\njtxcphmrjnscfhqhk6seven2threefive\nqd1sixninefour\nfour7fivethree65\n7dlzrddgrgfour3hxsttlnkbm29\nfour4twonine8\n5zblkgmxninesevenbrhntxm\nxfvl9589\nfive2seventhree6gbzb2\ncvmqqtskxlthree1\nsevenseventwo9xthreevzfdmfqvdf6\nsix72sixeightnine9\nxrjnqqtlxz8bbgsqrseven6two9\n29seven153eightzl7\nsevengntsfmzkfb8\n1fiveseveneightdbvbtszptqlnineseventhree\nfour6rks1v\n52eightninez\n5jspztgxrpt\nbq8jpttmm2\nfourctnlpkbrsfive9qd\n85twothreebbpsjcfh12oneeightwov\nxhxgfrcljq7six\nzh9\n9sixfiveseveneight\nrgqzbrldqrhtzjbsbzggktnc4nine8one1\nxcmfbrprxr72qqtnine\ntjphvghjfthree1one\ntwosixeight9fourone\neight48xronebc\nt6two34nkmfgmsnnvlbq3\neighteightkx86\n82b6fcvvxpsx84\nthreeeight66two\nsix4pkbhtxlteighteightsix\nthree7snrrdfb8sixninetwo4mltj\n5jqbgnqthreemjzgbvpdeighteight8tvf\nnine6zrbpsfrfqnsixlkmxrkxln\n2fivedvkt2998\nj2eightzqspbs\nmmp694eighteight\n3chzvrsrhzrcrtwoone2\nqqqzxcqmbb8nine\nsixsone7onesix1vvrqszvmnrh\n8threegtfnmkgthreesixthreeglhzqq\nthreefiveone2three6seven4\nsixzkqbcg1\ntwo7seven85five\ncfhg3zmpfd644\nbtsrthdbkt6242dhl\nhqlgnine5two\n2zgftzs8twovt\nmmpcgngmjjvbnsix35threezxjjxsqnlv\nlmmqsevenvjcvcqj55fiveninernmn9\ntwo7rgsbxnmddtjd\n36foursixsevencjffhxrsq\n4jxzfhxrphtgbjqfivefive\n99pqtnvtwo9crsbvsnrmtpltthree\nthreedhk3hgvkp8nvbk6\nfivelkxdgvsq6twofive9hzjkdz\nps7two9pqnnnvqpdbcpttjgrjl\njjcfkvqdcl4twothreetwosix\n47one525\n23three2\neight9four7gddxxfxcm9gdmmnfvbxr1\n745\ngkblgnrzsblklpb5bc8ftrnineoneseven\njghbzdlmqbjm5glsqfffvzksc\neightsix1five\nnznrzbdsv4\n16vdxm2hlrgtvgtdrbsix\ntxk26eightnrjxrrlvffour2\nthreesevenddmrsghzsjk2bdcqx\neightthree9blrfjvrpfnjcfqrxcnine1\ntwo7three81htcdvdnxg\nseven1three6\nkplnzdjmkcrthreefour38\nbvf1sevenmcdfnv9lpnnh\n6eightqcznninesix\ntwo3sevensnpf6v\neightthreeeight4986\n9seven7nine6nineseven6\n3two91\nsix97three26hlxczxp\n65twopggttdksmtsblfpjbcphzc8eightwopx\nmbxtfmkfourrkspbkvbrnljsjhzpqsgtvrr2\nsixseven9one5\nthree7twob98\n6c\n5797xjtwo83\nchrbcms6vpmrpctssbvqmvreight76\nmthgpstgchone6two\n597\n1799gjjdgzhg9eight\nvzqkgj27zpvxltzvrfcl47\n381lmxkxrfhbxqeight89tdhpbpqnx\nsevennine4\n29ninetwo1tvhpr6three\ndlbqfsdmdxhszmcpzshdthree3hvc2csbtfthree\n19khmsnhone\ntwofourbtlsl1\n3sevenssevenfivefour\n8seventhreesevenseven\nthree27rseven\n1jbdtfcdvvbzhgfsixrzqxkfktjmhkhfive5\nonetnznrrcthreefmmfivesbsvg4twothreetwoneqq\nsbjfxeight2tzbdkvqmmdd2\nvc4xfsjmt\nbfive9dmqgfnzvtngkbvthlrfjmsjtclbzbszfour\n31nbzfqvckd\n26kcdkzbjnpkpljxhgnhjgmtbrvkntjbqtwo\n3eightthree\neighteight88\nfive6bsix3rkchjzlfour94\none9rrrbx3eightone\n6fourkxpdmt852eight\n8xhfbqqklnfive2one\n4ninetwoone6\nseven5seven\n1vzprkvk\nmczkrcdx7rzvgdd6ktcnktpfkpp\nsixnine988one\n68shx\njqfoneight4sevensevenhmcrqjlzhnl6vcsqgmgnnxqhvchx8\n1fourgqbjvjhzdppdq\nlcxjghp2\nsevenone8nlh5\nnine94krdvjv5seven3\nninenineseven8threentgtlzfnrfbhxxzn8jt\nnine37\nhbzztninexrrktrlktwohr1765\n5sixjdvfxdxslhthreethree\n2eighteight\ndfnbf65\n4onenineqjnlpninekgk\noneoneeight974\n4nqqm83ninezkmbcblh\n7tpjhbeight1\nfiveninefdcnfourvdjcnsshnine3fivefive\n344\ncrnqzpztstxvcgjdmkp6\nhgcvbscglp63tpfive\nseven5fivesixcbtblmlsixgvfbqttzonedld\n43threep\nzshzcplxth4nine2zcgsbzdlxtzbxggnine\ncqtwoneone9ckhnzmzfsevenfour8j3\nfiveshs8ttpcsznh\nhdpqds3seventwokbzlhxpj\njoneight9\nhmxxnxhqfivefiveseventtgxqcxc3\n59sixoneonezjgbshzpfg\n1gqqz\n8two38fourjm7\n1fiveeight1four69\n88eightwoffg\nthreenine3threegqvtvtxgninerdprd\n7sixthreesixsixmgzlqlbsslseven7\nthreegmrbgmsfourfourbvmhzpctkd5rzx98\nfive193146mmqmf\n41fourxone\n2jhgqrkmmgbthreeeighttxg\n5xxbgpmm3\n5twonineffsevenfivetwonine\nseven98\none7532rcc\n8djrctpqvpcd\neightqqnhfnn2pjsevensixx7nine\njkzjrbhsevenseven1\n4tnkqxkl69nrktzz\nsix88five9nplcm\nxngrktpqclsmkqggj935oneeight\n8fourgbns\neight47nine1two147\nvpshrqvfkjctpmhcfc22eightmqdxlsngbfn\nrfive1kxfbcpq\ntwompnqfvqxqninevgvhqlpfqc15seven5eight\n9fournine4ntvhbkbhqn48mqhqhltbjpzrrgb\nninesix2four937\n6cxpmgqnchk33mfdxfqdhxbfiveonethree\n9mqmldz3kjnsgfoureight\n4dmxtdvqvrvdrbfour5q\n8eightmcsbfive11four2thqxmbktdl\nzddeightwosixlmhrzfksevensevenfive3seven7four\nlvgfftzceightsevensevennineseven5twobkd\nnine7three\nzlmfvjfrxrrdmtxg965msd4\ntwo9five4sevennmrvdgzrf1bjdzbtrdlb1\ntjbnzrpzrflpfsrprsg9\nfourzcqfonesix279\n75fxlvc\nldvmnfqpll7fourqxzpfctfxp1nhrhpvkbtmone\nseven4ninebpbdfjsxxmbqvtwo6one8\nfivefive47seven\nrxeightwomgzhcbnlmj72\neight34xhbcmeightfour3\nnxszsbltqhthree4\n7threefiveninecqzfdjpdcg\nkdfour2\nktworhdsfhhfqcrbzdslthmt2\ndpjbqmd7689\nthreesix8\n61113threenine\nninenine77fhtvsmfh23onefour\nbccdxg5three\n2eight1bnrx\neight7sixdvvrqgt46874\n35onekpnthreeprznkpfvlneightwom\n52five6\none3foursjnngjznqkfqklhjn\neighttwomzrxzfqgtdthree3scbjdnq\n9fivecjgdnkxrt\n5nine442fb8\nnine6one\n241fouronenrlb6\n97sstjznxfcpccngfl7cxmzzcvptfive\ngvtsxbqzcone52\n5845836fourfgrvrchv\n7247zxfkqhvd\nfourxtwonine2eightfive\nznjxhfour229three\nfiveone8qjfmjbnnc\n1sqdjlfiveh\nfivegxfj9pfbxf5\ncnxmvmcrm4cfivedcnrnneightwosd\nfour3oneone\nhbtfjlnplcsrxkt6rcqpfdseveneightwoh\njqknine9xfour43sevenbgznxhh\npvtztgjv47\none9oneeight\n3npsq\nninekmzdninejk7\n6threeninefhcpbb\n266\npvtwocthreeeight1\nlpmshscqztgsgsb2zfcddqnvkseven\ndmoneighteight78oneeight9zqszseven\neight8eight\nfcdlflbtfiverxfx9\nfive7six5\nhhvmsspr4four8hhcjdhnthree\nthree8qfzjpdztwodrkg5cg\n919lhzrx1\nfoursevenfourfive6lvfour57\ncrzmt7\ntwo71pzxnxtjkngfzm\nsixbmzlvcnine9\nhfbeightwo3eightfoursixfive\nj5twotwo57nine\nrmqq3sbjqnqmdjhmbp91hp\n3threezr\nfivesixfour81jqxx\n2bfeight7nine7\nfourfiveqjfkzsdxmgjmpmtone3hbgcvq\n7nrshoneninetwocpphnrfprz2five\ntwoseven1bqjgdz2\none7qonevmvb4sixhsbqgp\nfivethreethreegmdh1\nlv7d89\n2tbrnmflxfhhsixddn\n6sevennlhxsevensixt\npd2kkfvtjbbgvfrcts\ndjfoursevenflp2three6\nbppkvmxcrvffssdxgrr6mtlthree9six\n4szvlsixsevenxttwo\nppggtqx8\ntwo3three6five\nthreegplsmsjzjfcctwo6tkrkzmnk\nsrtj2tsnxthreeonethreep\nszhnzblxslqthreejveightfvrrhbcqjqmmvczh1\nfive2five25\nbtvlzjhrxxdqdmbbcrmbffpmlmr9four\n1jdrpjpvkmmseven\n85bbbht\n2onel2p\nhdsfftwotpqcgdbdjbgnvfone3eight\nfourdgtccrxdnvfszgkjsj38\ntwonine6twotvqxpskhonejsnpmtpctjfive6\n29eightcgskgdnmnhkpp63seventwo\n2seventwofhktwo9\n8kx\n32zxdzvfzjvtwofive9sevenfive\n2seven8pmdnnthreehnvltl7\n33sevenfournvnjp24\ntwo3m9kcsppfour\nhjfb9six5gtbppmzlfmfourtwodqzppcldd2\n4qlkz3\n4ninejzgpnkvq\nfbcpkspbcgrn6dmclmnqldeight\nsixtwodphp833\nsevenonesix5eightsrzpjzpj45rczn\n9fiveltfqjmkzbrm8oneightbq\nmxfqsrs5fpeightfive7mvclrlqhhkptpbqq\n438rktthreegvhltmsv\ndcl9xnntwosixthreesix7\ncsxhsvkkkhfour4slkvjk1eight89\nthree2eightfiveone\n17kqnstzmbthree9seventpld35\nztxjhftwo1f\nccfvc3three9five\nfmngmbkjppkxjnzqbqldmspbrrrhhrkrsix4\n9fivejthreepjtmtfive455\n4ncdvqfiveonefive5zxgjpptbnbsmbrfdpqrjnx\nljctvztrxncpxsdtttwo2tnkkt\nfive544mlzkztsblt17fivesix\n9five35bkbpjc\n6fourtwo\nnine5hqlbjp1onenvvnvsseven\n5qbvsbxtktqhgqxfgprsgsrrpdtpcmr8\nhhsgjxlz3gzxhz14fourtwofq\n6three8rmtrbnhvr\n9bhxvmhldnm6\nvkjjpkgdmxrzzfour7\nrhvrsrthsevenfour3eight5one73\nmsqdzmfzfeight6qhrvzcdxfourrleight84\npjtfflgfhqnpdk6three63five9six\n1sixcpcvbnnine9eightonenlnjfdfdmxcmcb\nzpgrbsevenmqskhgtrm6\n8hnqmmgrnsxhrxjjc2qjbbvpknh82\n5six7threepx\nbmlxvnqrxtqzkdlnnine5two9bpphfdhqj\nmtxrblghxrsbxhmgnbvgvffivenine49ztktxvfvseven\ntnqclrllq9fivebddnv\n56seven222pkmqk\n74eight9pfqghssgk\nnhmzdpbnlreightqgljp6\nnf3three2\neight9glknfltsqsfdsixfour2tcfnzfmf\nfour1ninetwo4sckcbgzrx663\neightbcfsevennqznfmfivetwo7qgdjtwo\n64three\n8vgggxllsrhqjh2\n7jhthmpmlxlptgbnscxcthreeeighttwo3seven\nktqlfveight1eightjnfxvvjk\n99qjcxgnpdvnbjqprbqnsjone3ninenmxkslmdsx\n9gn2\nqtlztwo7eight2\nnvzhsjsdp4sgrbmx36\nfldvmnlkq52nqtsccgfgtwolm7mmb\ntzvgkfx6ssnxfeightwov\nrrl8pxjj6onefour\n3hzhqbrdspfrn2eight8\njcrcxtqh8three4\nttwone449cxvvljcpzpqmngtzslnq\n3gnkgbjnsmxv2fourd8\n9zt\nkckeightsix8oneeightsix36\nvjcg4p\njkzr3\ntwofiveone1four9seven5cnhzm\n6one6\ns2twosixfvgrglfive2mtkrxznllj1\ncnhbzthlzllgghkxjgtrph45\nsix5two\nnine5threefournine\n1rkbvrk8threevfkdbvxgj\n28six7dvone8\n74seven\n6threeseven92rvpg1\nhxvthvgk8vhn6kmljfnl\nfourztpprfkonemnjbsfdjlj8\ndjnhxfxxl1five2threezgthn7\nvmhmlgljrpsix93sssixsevensix\ndqk8nrsrk\njjtdjkfivegpfspqqjthreedkntgjslqreight7n8\n8four12\n8vlcfsixthreelvvdv\nzsjqvmghp6seventwo\n6tnjfl2cfzcbgqp5\nvgjxleightzqfklqdx4vlpvp2gqxdxpzk4\n12mshtkbgsndrdx7three\nhtckznt2threeninej4fhmrtthreeeight\nfour8hdbrmptjnine\n2xbk\nljgcscxxjgdbpdpzfcchrqnmqqthree8\nthree7six51\nfour5five92ftqhjhx\neightfthreebzbhk4tceight\n2fivethreefiveeight9fbk\n9four613two8cnpzgcrnmc3\nfqfive38\nnine88mkthree99lkvzgvpjk7\n784dxxcpszbzkdlsrgnnqfsixone7twonemvh\nonetwo5tzggnsix2\nxsclx3twojhslqrnc32pxfqsjxctnb4\nzrdbcccznzlfgz8jfpgllczxtnpmp58one\nfour21one925rntdr\n38six\nseven3nfttdgkjhklmdqbkv8threefour\n75kblsbqhonevsx\nfourztseven8twothtwo\ngmktvrd44twonine4pnbrkhhzpl8five\nnineslj1six8two\none98mxnkrbv\n9zmfour\n8dkfmthstlqvs9r\ncjmcjjjvmceight9rslcctdslsxthreexsjbffnine\n5eight677\n4twothree\ncvqbrkmgthree4tbmzrhqtpx\n24twoone\nnphprsbcfhcfrggktgzgvrninesixdnchjd2\n9sevennmxzpjbhct\nsbchgzqgdk8twosix667\nhkjlpqgtmglv3eighttwo7two\ngflktjvlfivetbgmbsxzdpdxjdgkzvn851sixfour\nfive2ffivefiveonekldfpcfjg\nmlnvqltfsixnxqxsgfpxrpsxmmlnzsnineeight5\nsix1z\nsevenpvhgctkcvgtjstwoeightzgqlcgq1gxzj\nfivenine13rbbxfs1zpvrstlkceight\n6zmcggdqbfptwofourfphdbdg99four\none65ninetljqcfive8\nsix57fourthree4fzctnjzcdm\n181one\n3one315gftsbtnggrq\ngcdvnzbvv55onemgcftkmzrxf\n697cnzql8eightvdsngsglkfour\nfourfiveqjptdn6\npq83six7fprdbzvmgrhkzmjmxgnkcr\nnineeightfivesix8\nfiveseven931xhtnvrtr9three\nseven9ninetkhldts\n6threehlzfbppqmhrtxnfoursix2cxn9\nmphgdnggjt3flmdz14ninejjskfivenine\nboneight7one19179\nnpdjlhskrdmvsvhtldsthree5tpt\n6rvpnvdqqpkkfvgclctqcmpdfvftt68\n91four3twoones\nseven793\n8h2four6cdsevencsjvcgdlrj\n4bzxqvp74mmdvjfdvq4fivec\n31tlvlrb75\nnndfct5ninesix\nncqsnf6six\nfiveonefour8\nsixtwo6zjhvhkoneeighttbfv\nthree5dcpmcsnmfhtwo5\neightnqqkpnine4ninegb\nlgnsrbbtkgtwo7eightthree\nrlpcrnscknpjpqm2qqpllrzk8p9\ntvpqncpmffpmv9nineninesixnjbhbhgdlf2\nlzrhjdkfhn1\njgjfckbrpvc3fouronefourfive3eight\ntwozhkpzcdkjfour8eight\n5sevenfourtwo4\n1sevenfivehvppxvxvcnsnhdrflonefour\n4pshnstwo46fivetwoone\nthree1onemdlc8pcqkzsrnhqone\nqvgfvfxnrp5bqdrlqd\njzgcnslrfxxc72bqqqrzltqm18four\nnmjlnxktmvzzrgkbrffourdddbbt7eight\n3two9twothreerlztqftcgkznfour\n8fivefive5tkv\n4vtsnlclbb37eight2xprhpnddzj9\n8hbmfjxmqckxqrdjqxrnhg\nonef6\n8fivezcjtworgbxrfkjkbk5mdkdgfbnkkkljlv\n5six6prgqhbvcrr1msjcct\nmvzdrmdlrsdz9nqmbkb6286\n367\n94vjktbt\ntwofivefour7three454\n2n\nsix224\nz841dzxcthdx\nfourvnlj7twocchdcn976four\nthreexmxq5five\ndscbqrjqmssnzbbdtx34\n8sevenhrvzqskpczsfhzrhrfch\n4qx\n6eightnine\ncnbxjrbsseven8hbdfmjvk6sevendrglnfq3six\n82threengstmq\n19f\ncvjrhrnxnfiveksrjgh8\n2six1dlpdds\n5xzhhnqpnsix8qthckdhggfdfour7\n9threetwoqznvtb4\none8dseven\n3fivefourjzbk4seven8tvqgvh\n9kffjzvfxtwofive3seventhree5\n5onerxdcrrlgvfbrvrphnine5eight\n614pnrbdp\neightfour1cvxjbztxgzznlpr8qbzkz35\nfour5seventwo3\n9fourzzjfdqdkmxbeight41eightwopr\neight6rfdhz793twonevkf\nvmrkgjgthreethree8ninesevend6hmjmkfdqz\nvqstkklpj4j8\n72jglrpp57nine7vcr\nsevenfbbgpxlvk7tmlvtjsixdtrnseven3d\n5jlb4\njhkslf976fpseven\njpfive1\ntwo2jpfztkeightssfsevennine56\nseven6rjchpgvmqgrxdddq\nfour7eight\nzqoneight9mqmjtjcb\nljcmvjf1ngrgzmttttqprks2kphjtgqvmeightvfmzqhdhgj\n77ninejjxxgbffive6zzgd\n4pthree5zp3one\nmhdzcmmsseven4three3bngxxqzclpkmcppxtwo\nbneightwo33ptmpcbfournine4five\nsevenfrzffbklg4dmdngxmsixnzjgpkngsfivetwo6\nsix2onethreethree\nxhx4gvkbtcjbqvrhtwo6\n1mdfvninevchtrqthree\nonecrnninedjchhzkmzthree4qjnclshjlbn\nthreeccgbz6sixlhnkcpfdzk119\n61dtwo\nncsbdxnp43jlrxfhgzlrfzqjkzbkd\nnxfztwo9lhcc\nmds9vkninehzcdk\ntwofive4jdcndg\n374\nthreedrsh9eightcqkrslljl5tthree\nfourtwotwo8kl1bvplqfrc7\nthreekldmmjkmc92sixsixonenine6\nbllccpcksq59zznr\nn35lxtnq3\n25hmzzxv\n38sevenkqgtfcpnj\nntfceightmvhvnzjvv37bsj\n4sixfvrtgdsjvxsevenfouronefiveddns2\neight29lnznht2oneonekgjkq\n4lthkrtj1onesevenninerfplsixfhxdvlhoneighth\n1seven8eightgxzvgmnqj\n7qfqvxcjttwoeighteightqqsgbsftseight\nslfqkljnine1oneeightlgskmlqgstwo\nsppqhlxqzkdtdqc6qtxsssdcf41\ntnggpjrnmrrgzpssptpk32\n6pcjglgdknjoneightssb\nninefivefrglbccjmrchvbpsgxrq15fourfive\n7five1lmndzphnj4fouronesj\njvhkb24htseven7\n7sevensjnrvxmsixthreesevengrh\n9h5xbdgpdjjkt1\nc14vbjvcv\nninetwohfbm6fourjpgz676\ngqdtlzqvkplj48cxvtvjjlkmbstcfxd5hkbfdgtf\nninelpxd8eightvmmbvgmhs3six1\n9mmlj4vvcxlnbsfoureight\nnzrjlxqhnffour1\nhl5fzsxdbvklx4five\n182ninedghflcgrqz4ns\neightdmbqddsqmfive7qshcvdjx\nvdfzsevenoneone4ninemhclrkjspkxt\n2three1qzqhscbvmpnine86three\n1ninevvlzft\n1ghfnrvkn97sixqzgtm32\nsixnine4rsjghcsznfvs\nph5mzknlknp5\n3eight3twotchnsqdtbkh\n63threerjlgv6three\nfivevvcmvrqfkdfshxjnfgsevensix3seven8\n21onebcsgvhtm6two\nbnjpqcqdzmeight2gtjhqeight\n1rsjbbhtkbbfourqzdhlone4eighttwo\n6jpnnlbstgjfjdrdgnthreepgh49hdxqghr\nfive3oneonefrvnbnnlz\ngbseven9five6\nnine2hdltdjdp73phzrjnonegx\n3two3eightjszbfourkxbh5twonepr\n5cfprzgxtf3465five\n",
  "example" => "1abc2\npqr3stu8vwx\na1b2c3d4e5f\ntreb7uchet"
}

response =
  for part <- ["part1", "part2"], input_key <- ["puzzle", "example"] do
    {part, input_key}
  end

response =
  response
  |> Enum.filter(fn {part, input_key} ->
    part in run_config and input_key in run_config
  end)
  |> Enum.map(fn {part, input_key} ->
    [part, input_key, Smaoc.Solution.solve(String.to_atom(part), inputs[input_key])]
  end)

Smaoc.Response.new(%{response: response, run_config: run_config, year: year, day: day})