adventofcode-0.1.0.0: Haskell solutions to adventofcode
LicenseMIT
Maintainer@tylerjl
Safe HaskellSafe-Inferred
LanguageHaskell2010

Y2023.D03

Description

Solutions to the 2023 day 03 set of problems for adventofcode.com.

Synopsis

Documentation

data Instruction #

Constructors

Symbol 
Gear 
Digit Char 

Instances

Instances details
Show Instruction # 
Instance details

Defined in Y2023.D03

type Point = (Int, Int) #

type Parts = Map (Set Point) Int #

part3A :: Text -> Int #

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.

part3B :: Text -> Int #

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 #

fromGrid :: (Point -> Set Point -> Set Point) -> [(Point, Cell)] -> (Symbols, Parts) #

parseSchematic :: Parser [(Point, Cell)] #

parseRow :: Parser [(Int, Cell)] #

cellP :: Parser Cell #