From 680a7fda6c8dd296dbb9c694e67de4ca29441370 Mon Sep 17 00:00:00 2001 From: Tim Stallard Date: Mon, 5 Dec 2016 08:22:12 +0000 Subject: [PATCH] Day 5? --- day05/input.txt | 1 + day05/part1.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 day05/input.txt create mode 100644 day05/part1.js diff --git a/day05/input.txt b/day05/input.txt new file mode 100644 index 0000000..1acf64c --- /dev/null +++ b/day05/input.txt @@ -0,0 +1 @@ +uqwqemis diff --git a/day05/part1.js b/day05/part1.js new file mode 100644 index 0000000..676bedd --- /dev/null +++ b/day05/part1.js @@ -0,0 +1,20 @@ +var input = require("fs").readFileSync("input.txt").toString().replace(/\n/g, "").replace(/\r/g, ""); +var password = []; +var i = 0; +while(password.filter((a)=>(a)).length < 8){ + var md5sum = require("crypto").createHash("md5"); + md5sum.update(input + i); + var hash = md5sum.digest("hex"); + if(hash.slice(0, 5) == "00000"){ + var position = parseInt(hash[5]); + if(!password[position] && position <= 7){ + password[position] = hash[6]; + console.log("FOUND", i, password.length, position, hash); + } + } + i++; + if(i%100000 == 0){ + console.log(i); + } +} +console.log(password.join(""));