Skip to content

Instantly share code, notes, and snippets.

@esad
Created December 8, 2016 22:12
Show Gist options
  • Save esad/918b0215e598be4ea30eb89e0898c49b to your computer and use it in GitHub Desktop.
Save esad/918b0215e598be4ea30eb89e0898c49b to your computer and use it in GitHub Desktop.
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