Last active
December 9, 2015 18:09
-
-
Save daronspence/0b07ad7e0a1c56a60d4e to your computer and use it in GitHub Desktop.
Advent of Code - Day 4 Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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