projects
/
advent-of-code-16.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e78bf6c
)
Tidying
author
Neil Smith
<neil.git@njae.me.uk>
Wed, 21 Dec 2016 15:59:32 +0000
(15:59 +0000)
committer
Neil Smith
<neil.git@njae.me.uk>
Wed, 21 Dec 2016 15:59:32 +0000
(15:59 +0000)
advent21.hs
patch
|
blob
|
history
diff --git
a/advent21.hs
b/advent21.hs
index fdb13814d3d6c07c0a098fd5ef0a975ad1a2696b..d51bd1076273b81be19b30fd0980a4511d47ffe8 100644
(file)
--- a/
advent21.hs
+++ b/
advent21.hs
@@
-1,6
+1,5
@@
import Text.Parsec hiding (State)
import Text.ParserCombinators.Parsec.Number
import Text.Parsec hiding (State)
import Text.ParserCombinators.Parsec.Number
--- import Control.Applicative ((<*), (*>), (<*>))
import Data.Maybe (fromJust)
import Data.List (elemIndex)
import Data.Maybe (fromJust)
import Data.List (elemIndex)
@@
-58,15
+57,19
@@
main = do
part1 :: [Instruction] -> String -> IO ()
part1 instructions start =
part1 :: [Instruction] -> String -> IO ()
part1 instructions start =
- let state = Password {password = start}
- in print $ runIdentity (runStateT (runWriterT (apply instructions)) state)
- -- in putStrLn $ password $ runIdentity (execStateT (runWriterT (apply instructions)) state)
+ let st = Password {password = start}
+ ((_, log), st') = runIdentity (runStateT (runWriterT (apply instructions)) st)
+ in do
+ -- putStrLn $ unlines $ map (action) log
+ putStrLn $ password st'
part2 :: [Instruction] -> String -> IO ()
part2 instructions end =
part2 :: [Instruction] -> String -> IO ()
part2 instructions end =
- let state = Password {password = end}
- in print $ runIdentity (runStateT (runWriterT (unApply instructions)) state)
- -- in putStrLn $ password $ runIdentity (execStateT (runWriterT (apply instructions)) state)
+ let st = Password {password = end}
+ ((_, log), st') = runIdentity (runStateT (runWriterT (unApply instructions)) st)
+ in do
+ -- putStrLn $ unlines $ map (action) log
+ putStrLn $ password st'
apply :: [Instruction] -> App ()
apply :: [Instruction] -> App ()