License | MIT |
---|---|
Maintainer | @tylerjl |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Solutions to the 2023 day 03 set of problems for adventofcode.com.
Synopsis
- data Instruction
- type Cell = Maybe Instruction
- type Point = (Int, Int)
- type Symbols = Set Point
- type Parts = Map (Set Point) Int
- part3A :: Text -> Int
- part3B :: Text -> Int
- filterAdjacent :: (Ord a1, Applicative f, Monoid (f a2)) => Set a1 -> Set a1 -> a2 -> f a2
- fromGrid :: (Point -> Set Point -> Set Point) -> [(Point, Cell)] -> (Symbols, Parts)
- neighbors :: Point -> [Point]
- toDigit :: Maybe Instruction -> Maybe Char
- parseSchematic :: Parser [(Point, Cell)]
- parseRow :: Parser [(Int, Cell)]
- cellP :: Parser Cell
Documentation
data Instruction #
Instances
type Cell = Maybe Instruction #
Solve for part A - just construct the two structures and them find members of the map that overlay with symbol neighbor points and sum them up.
Solve for part B, this one is a little more complicated.
We still parse out a set of gear points and a map of all numbers and the points they cover, but we need to walk through the set of gear points and filter them based upon whether they have two neighbors after filtering the number map for nearby numbers.
filterAdjacent :: (Ord a1, Applicative f, Monoid (f a2)) => Set a1 -> Set a1 -> a2 -> f a2 #
parseSchematic :: Parser [(Point, Cell)] #