diff --git a/advent.ipkg b/advent.ipkg index 189172e..c9776ba 100644 --- a/advent.ipkg +++ b/advent.ipkg @@ -28,6 +28,7 @@ modules = Runner , Util , Util.Eff , Util.Digits + , Grid -- main file (i.e. file to load at REPL) main = Main diff --git a/src/Years/Y2015/Day11.md b/src/Years/Y2015/Day11.md index 43d7908..0f6ccc6 100644 --- a/src/Years/Y2015/Day11.md +++ b/src/Years/Y2015/Day11.md @@ -183,8 +183,8 @@ containsPairs xs = length (nub $ pairs (reverse xs) []) >= 2 Combine our password criteria into one function ```idris -passwordCriteria : Vect n PasswordChar -> Bool -passwordCriteria xs = incrimentingChars xs && noInvalidChars xs && containsPairs xs +part1Critera : Vect n PasswordChar -> Bool +part1Critera xs = incrimentingChars xs && noInvalidChars xs && containsPairs xs ``` ### Find the next password @@ -207,30 +207,19 @@ findNextPassword f password = ### Part 1 ```idris -part1 : Eff (PartEff String) (String, Password) +part1 : Eff (PartEff String) (String, ()) part1 = do input <- map trim $ askAt "input" password <- parsePassword input info "Starting password: \{show password} -> \{passwordToString password}" - let next_password = findNextPassword passwordCriteria password - pure (passwordToString next_password, next_password) -``` - -### Part 2 - -```idris -part2 : Password -> Eff (PartEff String) String -part2 password = do - info - "Second starting password: \{show password} -> \{passwordToString password}" - let next_password = findNextPassword passwordCriteria password - pure $ passwordToString next_password + let next_password = findNextPassword part1Critera password + pure (passwordToString next_password, ()) ``` ## References