diff --git a/app/Inputs/Year2024/Day04.txt b/app/Inputs/Year2024/Day04.txt new file mode 100644 index 0000000..72f4b39 --- /dev/null +++ b/app/Inputs/Year2024/Day04.txt @@ -0,0 +1,140 @@ +ASAMXSMXMAXSAMMAMXAXXAXXMSAMXASAMXSASMSMXAXMAMMSSSMAMSMMSASMMSSMSMSMSXMMSXMXMAXXMAASMMMXMXMMXMAMXSSSMSMSMSMMMMAMMSMSXXAXMMXSAXMMXXAMASMXMASM +MMXXAMXAXSMXMMSSMMSSMSMMXSSMXMAASASAAAAMSMSMSSXAMXXAMXAAAAMXASXAAAAAMASASASMSSMMMSXSAMXAMAMSSMASAMAAAAAAXXAAXMAMXSAMAMSSMAMXMMSMMXSXAMAAASAS +SAMMAXMSMXMAXMAMAAMXAAASAMXSXASAMAMMMXMMAXMAAXMXMMXSSSMMSXXMXMASMSMSMXMASAMAAXAAAMMSMMXMXAXAASAMAMMMSMSMSSSMSSXSAMSMMMAAMXXXAAAAAMAMSSSXMXAX +AAMSAMMAMASXSMSMMMSMSMSMASAMMMMSMXMASXSSMSMMMSMSXAMXAASAMMMXSAMAAXAXMXMAMXMXXSXMMMAXASAAMSSSMMXSAMXAAXMAMXMAXAXMXAAXMMSSMMSMMSSSMAMMAAAMMMSM +MMMSAXSMXMXAMAXXAXXAAXXMXMASMAAXXAXMSAAXSAXAAAASMSMMAMMXSAXAXAXMMMMMMXMASXMSMMXSAMMSAMMXMXAMXMAAXXMSMSMSMMMSMMXSMAMMSAAAXAASXXAMASXMMSMAAAMA +XAAMAMXXSMMMMAMSSMMSMSXMXSXMMMXXMMSXMMMMSXSMSMXMAMMXAMMMMMMXMMMMMAXMAAMXSXAAAXAMAXMAMMMSSMSMAMASAMXAAAAAMXAAAXAXAASAXMSXMSSSMMMMAMAMXXXSMSSM +SMSSXSXAAMMAMXXAMAMXXXAMMSAMXMXSMMAXMASXMAMAAAAAXXXSMSXASXMSXSAMSMSMMMSAXMASMMXSXMASXAXAXAMSXSAXMSSMSM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MXXMSMSXMASAMAXAAAAAXAXMSMMAMAXAAMAAMMAMASAMXSAMAAMAMXAAXAMMSMAXAXSXXAAXXXAASMMASAM +MAXXSMMMMSMMASXAAMMSXMSAAXMAXMAMSSMMASXAXXAMAAAAMMMMSAMASXMSAXAAAAXMXSMMMSMMMSASMMMSAMASMMMMMMMAMXMSAMXMMSMMASMSMMMSAAMMMMMMXXMASMAASMASASAS +XMSAMXAAMAXMXSXMMSAMXASXSXMAXSAMXAASAMXAMSAMXMSMMAAMSASASAAXMMSMMAMSAAAXMAMSAMXAAAASASASAAXXXXSASAAXMSAXMAASASAMAXMMXSSXXMASAXXAMXAMXXXMXSMM +AXMXMSSSSMSMXMASAMXSMMMXAXMAMSASXSMMMSAXMSXXAXMASXSXSMMMSMSMXAMXSXAMSSXMSXSSXXSSMMMSAMXSXMSAAXSASMSMXSASMSXMASMSSMXMAMMAMXASASXMASAXSAMXXMAS diff --git a/app/Year2024.hs b/app/Year2024.hs index e7421c6..970b7ac 100644 --- a/app/Year2024.hs +++ b/app/Year2024.hs @@ -6,8 +6,8 @@ where import qualified AdventOfCode.Year2024.Day01 as Day01 (run1, run2) import qualified AdventOfCode.Year2024.Day02 as Day02 (run1, run2) import qualified AdventOfCode.Year2024.Day03 as Day03 (run1, run2) +import qualified AdventOfCode.Year2024.Day04 as Day04 (run1, run2) --- import qualified AdventOfCode.Year2024.Day04 as Day04 (run1, run2) -- import qualified AdventOfCode.Year2024.Day05 as Day05 (run1, run2) -- import qualified AdventOfCode.Year2024.Day06 as Day06 (run1, run2) -- import qualified AdventOfCode.Year2024.Day07 as Day07 (run1, run2) @@ -50,11 +50,11 @@ main = do print $ "Result #1: " <> Day03.run1 fixture print $ "Result #2: " <> Day03.run2 fixture --- do --- print "Day04" --- fixture <- readFile "app/Inputs/Year2024/Day04.txt" --- print $ "Result #1: " <> Day04.run1 fixture --- print $ "Result #2: " <> Day04.run2 fixture + do + print "Day04" + fixture <- readFile "app/Inputs/Year2024/Day04.txt" + print $ "Result #1: " <> Day04.run1 fixture + print $ "Result #2: " <> Day04.run2 fixture -- do -- print "Day05" diff --git a/src/AdventOfCode/Year2024/Day04.hs b/src/AdventOfCode/Year2024/Day04.hs new file mode 100644 index 0000000..8cd74bb --- /dev/null +++ b/src/AdventOfCode/Year2024/Day04.hs @@ -0,0 +1,73 @@ +module AdventOfCode.Year2024.Day04 + ( run1, + run2, + ) +where + +import Data.List.Extra ((!?)) +import Data.Maybe (catMaybes, mapMaybe) +import Debug.Trace (traceShowId) +import Prelude hiding (Word) + +type WordSearch = [[Char]] + +type Word = [Char] + +type Position = (Int, Int) + +allDirections (x, y) = + [ [(x, y), (x - 1, y), (x - 2, y), (x - 3, y)], + [(x, y), (x + 1, y), (x + 2, y), (x + 3, y)], + [(x, y), (x, y - 1), (x, y - 2), (x, y - 3)], + [(x, y), (x, y + 1), (x, y + 2), (x, y + 3)], + [(x, y), (x - 1, y - 1), (x - 2, y - 2), (x - 3, y - 3)], + [(x, y), (x - 1, y + 1), (x - 2, y + 2), (x - 3, y + 3)], + [(x, y), (x + 1, y - 1), (x + 2, y - 2), (x + 3, y - 3)], + [(x, y), (x + 1, y + 1), (x + 2, y + 2), (x + 3, y + 3)] + ] + +cross (x, y) = + [ [ (x, y), + (x - 1, y - 1), + (x - 1, y + 1), + (x + 1, y + 1), + (x + 1, y - 1) + ] + ] + +allPositions :: WordSearch -> [Position] +allPositions xs = (\(row, x) -> (\(col, y) -> (x, y)) <$> zip row [0 ..]) =<< zip xs [0 ..] + +(!??) :: [[a]] -> (Int, Int) -> Maybe a +(!??) xs (x, y) = do + row <- xs !? x + row !? y + +process :: WordSearch -> (WordSearch -> Position -> [Word]) -> (Word -> Bool) -> Int +process xs lookupCandidates isWinner = length $ winners + where + positions = allPositions xs + candidates = concatMap (lookupCandidates xs) positions + winners = filter isWinner candidates + +process1 :: WordSearch -> Int +process1 xs = process xs lookupCandidates isWinner + where + lookupCandidates xs position = mapMaybe (xs !??) <$> allDirections position + isWinner = (== "XMAS") + +run1 :: String -> String +run1 = show . process1 . lines + +process2 :: WordSearch -> Int +process2 xs = process xs lookupCandidates isWinner + where + lookupCandidates xs position = mapMaybe (xs !??) <$> cross position + isWinner ['A', 'M', 'M', 'S', 'S'] = True + isWinner ['A', 'M', 'S', 'S', 'M'] = True + isWinner ['A', 'S', 'S', 'M', 'M'] = True + isWinner ['A', 'S', 'M', 'M', 'S'] = True + isWinner _ = False + +run2 :: String -> String +run2 = show . process2 . lines diff --git a/test/AdventOfCode/Year2024/Day04Spec.hs b/test/AdventOfCode/Year2024/Day04Spec.hs new file mode 100644 index 0000000..1babadb --- /dev/null +++ b/test/AdventOfCode/Year2024/Day04Spec.hs @@ -0,0 +1,50 @@ +module AdventOfCode.Year2024.Day04Spec + ( spec, + ) +where + +import AdventOfCode.Year2024.Day04 + ( run1, + run2, + ) +import Test.Hspec + ( Spec, + it, + shouldBe, + ) + +spec :: Spec +spec = do + it "run1" $ do + run1 + ( unlines + [ "MMMSXXMASM", + "MSAMXMSMSA", + "AMXSXMAAMM", + "MSAMASMSMX", + "XMASAMXAMM", + "XXAMMXXAMA", + "SMSMSASXSS", + "SAXAMASAAA", + "MAMMMXMMMM", + "MXMXAXMASX" + ] + ) + `shouldBe` "18" + + it "run2" $ do + run2 + ( unlines + [ ".M.S......", + "..A..MSMS.", + ".M.S.MAA..", + "..A.ASMSM.", + ".M.S.M....", + "..........", + "S.S.S.S.S.", + ".A.A.A.A..", + "M.M.M.M.M.", + ".........." + ] + ) + `shouldBe` "9"