Update aoc.hs
This commit is contained in:
parent
883cdcc797
commit
c9666b358b
@ -45,4 +45,4 @@ part2 :: [(String, (Op, String, String))] -> Int -> Int
|
|||||||
part2 wires part1Answer = fst $ eval'' wires [("b", part1Answer)] "a"
|
part2 wires part1Answer = fst $ eval'' wires [("b", part1Answer)] "a"
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = aocMain' parseFile (passthrough . part1) part2
|
main = aocMain' parseFile (dup . part1) part2
|
8
aoc.hs
8
aoc.hs
@ -9,10 +9,10 @@ aocMain' parseFile part1 part2 = do
|
|||||||
let part2Answer = part2 input data'
|
let part2Answer = part2 input data'
|
||||||
putStrLn $ "Part 2: " ++ show part2Answer
|
putStrLn $ "Part 2: " ++ show part2Answer
|
||||||
|
|
||||||
passthrough :: a -> (a, a)
|
dup :: a -> (a, a)
|
||||||
passthrough 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)
|
aocMain parseFile part1 part2 = aocMain' parseFile ((,()) . part1) (const' part2)
|
||||||
|
|
||||||
const' :: (a -> b) -> a -> c -> b
|
const' :: (a -> b) -> a -> c -> b
|
||||||
@ -21,7 +21,7 @@ const' f a _ = f a
|
|||||||
enumerate :: [a] -> [(Int, a)]
|
enumerate :: [a] -> [(Int, a)]
|
||||||
enumerate = zip [0..]
|
enumerate = zip [0..]
|
||||||
|
|
||||||
unimplemented :: Show p => p -> Int
|
unimplemented :: (Show p, Show a) => p -> a
|
||||||
unimplemented = error . show
|
unimplemented = error . show
|
||||||
|
|
||||||
pair :: [a] -> (a, a)
|
pair :: [a] -> (a, a)
|
||||||
|
Loading…
Reference in New Issue
Block a user