format day3

This commit is contained in:
Victor Martinez 2025-03-13 22:11:26 +01:00
commit 05900411a2

View file

@ -4,12 +4,6 @@ import Data.Maybe (mapMaybe)
import Text.Read (readMaybe)
import Text.Regex.TDFA
data ProgramState = Enabled | Disabled
data Program = Program ProgramState Int
data Instruction = Do | Dont | Mul Int Int
partOne :: String -> Int
partOne text = programValue $ foldl runInstruction initProgram $ parseInstructions matches
where
@ -20,6 +14,14 @@ partTwo text = programValue $ foldl runInstruction initProgram $ parseInstructio
where
matches = getAllTextMatches (text =~ "do\\(\\)|don't\\(\\)|mul\\([0-9]{1,3},[0-9]{1,3}\\)")
-- Program
data ProgramState = Enabled | Disabled
data Program = Program ProgramState Int
data Instruction = Do | Dont | Mul Int Int
initProgram :: Program
initProgram = Program Enabled 0