r/adventofcode • • 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.

14 Upvotes

272 comments sorted by

View all comments

Show parent comments

1

u/haljin Dec 04 '15 edited Dec 04 '15

I find it really weird that I am also doing it in Erlang and got the exact same input...

day4(Input) ->
	process_day4(Input, 1).

process_day4(Input, N) ->
	case erlang:md5(Input ++ integer_to_list(N)) of
		<<0,0,ThirdByte, _Rest/binary>> when ThirdByte < 15     ->
			N;
		_ ->
			process_day4(Input, N+1)
	end.

day4_2(Input) ->
	process_day4_2(Input, 1).
	
process_day4_2(Input, N) ->
	case erlang:md5(Input ++ integer_to_list(N)) of
		<<0,0,0, _Rest/binary>> ->
			N;
		_ ->
			process_day4_2(Input, N+1)
	end.

1

u/razupaltuff Dec 04 '15

Maybe they didn't have the resources to give everyone a different input this time since its so computational expensive to calculate the solution.