Created
December 8, 2016 22:12
-
-
Save esad/918b0215e598be4ea30eb89e0898c49b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreign import md5 :: String -> String | |
infixl 1 applyFlipped as |> | |
findPassword :: String -> String | |
findPassword doorId = | |
aux 0 Nil | |
where | |
aux :: Int -> List Char -> String | |
aux k cs = | |
case (doorId <> (show k)) |> md5 |> String.toCharArray |> List.fromFoldable of | |
'0':'0':'0':'0':'0':c:_ -> | |
c : cs | |
|> if k == 7 then | |
(Array.fromFoldable >>> Array.reverse >>> String.fromCharArray) | |
else | |
aux (k+1) | |
_ -> | |
aux (k+1) cs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment