Skip to content

Instantly share code, notes, and snippets.

@daronspence
Last active December 9, 2015 18:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daronspence/0b07ad7e0a1c56a60d4e to your computer and use it in GitHub Desktop.
Save daronspence/0b07ad7e0a1c56a60d4e to your computer and use it in GitHub Desktop.
Advent of Code - Day 4 Solution
// Crypto JS MD5 library was used. https://code.google.com/p/crypto-js/#MD5
var CryptoJS = require('./md5');
var MD5 = CryptoJS.Crypto.MD5;
var input = 'ckczppom';
var adventCoin = 0;
var i = 0;
console.time('mineAdvent');
while ( adventCoin === 0 ){
hash = MD5( input + i.toString() ).toString();
first5 = hash.slice(0,5);
if ( i % 25000 === 0 ){
console.log(hash);
}
if (first5 === '00000' ){
adventCoin = i;
}
i++;
}
console.timeEnd('mineAdvent');
console.log( 'The answer is: ' + adventCoin );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment