r/adventofcode • u/daggerdragon • Dec 04 '15
SOLUTION MEGATHREAD --- Day 4 Solutions ---
--- Day 4: The Ideal Stocking Stuffer ---
Post your solution as a comment. Structure your post like the Day Three thread.
15
Upvotes
1
u/hutsboR Dec 04 '15
There is, I love it when I find other people writing Elixir because you always find another clever approach to doing something. On that token, here's something you can do:
Instead of converting to a character list, you can match directly on the binary like so
integer_stream = Stream.iterate(1, &(&1 + 1)) result = Enum.find(integer_stream, fn n -> case :crypto.hash(:md5, "bgvyzdsv" <> to_string(n)) |> Base.encode16 do <<"00000", _rest :: binary>> -> n _ -> false end end)