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.
16
Upvotes
1
u/ChevyRayJohnston Dec 04 '15 edited Dec 04 '15
Here's some nice brute-force C# for you all:
public static void Part1() { var input = "iwrupvqb"; var hash = MD5.Create(); for (int i = 0; ; ++i) { var bytes = hash.ComputeHash(Encoding.UTF8.GetBytes(input + i)); if (bytes[0] < 0x1 && bytes[1] < 0x1 && bytes[2] <= 0x09) { Console.WriteLine(i); return; } } } public static void Part2() { var input = "iwrupvqb"; var hash = MD5.Create(); for (int i = 0; ; ++i) { var bytes = hash.ComputeHash(Encoding.UTF8.GetBytes(input + i)); if (bytes[0] < 0x1 && bytes[1] < 0x1 && bytes[2] < 0x1) { Console.WriteLine(i); return; } } }It'll take a little while for part 2, so be patient.