Update aoc.hs

This commit is contained in:
germax26 2024-12-03 08:15:27 +11:00
parent 883cdcc797
commit c9666b358b
Signed by: germax26
SSH Key Fingerprint: SHA256:N3w+8798IMWBt7SYH8G1C0iJlIa2HIIcRCXwILT5FvM
2 changed files with 5 additions and 5 deletions

View File

@ -45,4 +45,4 @@ part2 :: [(String, (Op, String, String))] -> Int -> Int
part2 wires part1Answer = fst $ eval'' wires [("b", part1Answer)] "a"
main :: IO ()
main = aocMain' parseFile (passthrough . part1) part2
main = aocMain' parseFile (dup . part1) part2

8
aoc.hs
View File

@ -9,10 +9,10 @@ aocMain' parseFile part1 part2 = do
let part2Answer = part2 input data'
putStrLn $ "Part 2: " ++ show part2Answer
passthrough :: a -> (a, a)
passthrough a = (a, a)
dup :: a -> (a, a)
dup a = (a, a)
aocMain :: Show p => ([String] -> p) -> (p -> Int) -> (p -> Int) -> IO ()
aocMain :: (Show p, Show a) => ([String] -> p) -> (p -> a) -> (p -> a) -> IO ()
aocMain parseFile part1 part2 = aocMain' parseFile ((,()) . part1) (const' part2)
const' :: (a -> b) -> a -> c -> b
@ -21,7 +21,7 @@ const' f a _ = f a
enumerate :: [a] -> [(Int, a)]
enumerate = zip [0..]
unimplemented :: Show p => p -> Int
unimplemented :: (Show p, Show a) => p -> a
unimplemented = error . show
pair :: [a] -> (a, a)