Created
December 4, 2015 13:53
-
-
Save ignaciovazquez/b0eb864a3c5e8e869940 to your computer and use it in GitHub Desktop.
Advent of Code. Day 4.
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
# Part 1 | |
integer_stream = Stream.iterate(1, &(&1 + 1)) | |
result = Enum.find(integer_stream, fn n -> | |
case :crypto.hash(:md5, "bgvyzdsv" <> to_string(n)) |> Base.encode16 |> to_char_list do | |
[48, 48, 48, 48, 48 | _ ] -> n | |
_ -> false | |
end | |
end) | |
IO.puts result | |
# Part 2 | |
integer_stream = Stream.iterate(result, &(&1 + 1)) | |
result = Enum.find(integer_stream, fn n -> | |
case :crypto.hash(:md5, "bgvyzdsv" <> to_string(n)) |> Base.encode16 |> to_char_list do | |
[48, 48, 48, 48, 48, 48 | _ ] -> n | |
_ -> false | |
end | |
end) | |
IO.puts result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment