From b08231886650f0b2037e264fcc9bfa84d0471ae9 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Sat, 2 Dec 2023 21:27:09 -0800 Subject: [PATCH] test case --- solutions/src/2023/03.hs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/solutions/src/2023/03.hs b/solutions/src/2023/03.hs index 30af4a1..e08e154 100644 --- a/solutions/src/2023/03.hs +++ b/solutions/src/2023/03.hs @@ -8,6 +8,22 @@ Maintainer : emertens@gmail.com +>>> :{ +:main + +"467..114.. +...*...... +..35..633. +......#... +617*...... +.....+.58. +..592..... +......755. +...$.*.... +.664.598.." +:} +4361 +467835 + -} module Main where @@ -19,7 +35,7 @@ import Data.List (find) import Advent (getInputMap) import Advent.Coord (Coord, left, neighbors, right) --- | +-- | Parse the input schematic and print answers to both parts. -- -- >>> :main -- 527144 @@ -30,6 +46,7 @@ main = let lkp i = Map.findWithDefault '.' i input + -- Map of each part in the schematic to the list of adjacent part numbers partMap :: Map Coord [Int] partMap = Map.fromListWith (++) [ (part, [read (map lkp cs)]) @@ -43,5 +60,6 @@ main = print (sum (fmap sum partMap)) print (sum [a * b | (c, [a,b]) <- Map.assocs partMap, '*' == lkp c]) +-- | Things that aren't digits or periods. isSymbol :: Char -> Bool isSymbol x = not (isDigit x) && x /= '.'