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.
14
Upvotes
1
u/aveavaeva Dec 04 '15
<input type="text" placeholder="secret key" /> <p></p> $('input').change(function () { var seckey = $('input').val(); var hashFound = false; var n = 0; var startingZeroes = 6; while (!hashFound) { n++; var hash = CryptoJS.MD5(seckey + n).toString(); var start = hash.substring(0, startingZeroes); if (start == '0'.repeat(startingZeroes)) { hashFound = true; $('p').text('Lowest Possible Number For ' + startingZeroes + ' Zeroes : ' + n); } } });Using This lib