Initial commit
This commit is contained in:
commit
cf2af11b6b
23 changed files with 3988 additions and 0 deletions
11
src/AoC/Util.hs
Normal file
11
src/AoC/Util.hs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- | Internal module in order to facilitate testability.
|
||||
module AoC.Util (solveRiddle, readFileUtf8) where
|
||||
|
||||
readFileUtf8 :: (MonadIO m) => FilePath -> m Text
|
||||
readFileUtf8 = fmap (decodeUtf8With lenientDecode) . readFileBS
|
||||
|
||||
solveRiddle :: (MonadIO m) => FilePath -> (Text -> [Text]) -> m ()
|
||||
solveRiddle file solver = do
|
||||
results <- solver <$> readFileUtf8 file
|
||||
forM_ (results `zip` [1 :: Int ..]) $ \(solution, part) ->
|
||||
putTextLn $ " solution to part-" <> show part <> ": " <> solution
|
||||
Loading…
Add table
Add a link
Reference in a new issue