From 05900411a2fe0f9c1075062d5df2a7e101c4fdf1 Mon Sep 17 00:00:00 2001 From: Victor Martinez <49537445+JasterV@users.noreply.github.com> Date: Thu, 13 Mar 2025 22:11:26 +0100 Subject: [PATCH] format day3 --- src/Day3.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Day3.hs b/src/Day3.hs index 6f75868..9b384e5 100644 --- a/src/Day3.hs +++ b/src/Day3.hs @@ -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