Created
December 6, 2015 05:07
-
-
Save daronspence/a0a12b54e8d9b2360418 to your computer and use it in GitHub Desktop.
Advent of Code Day 4 Part 2
This file contains hidden or 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(); | |
first6 = hash.slice(0,6); | |
if ( i % 25000 === 0 ){ | |
console.log(hash); | |
} | |
if (first6 === '000000' ){ | |
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