day 4,5,6

This commit is contained in:
2017-12-06 13:40:43 +00:00
parent 4f1bc11fa1
commit 2f00f67d4f
9 changed files with 1694 additions and 0 deletions
+1090
View File
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
var offsets = require("fs").readFileSync("input.txt").toString().split("\n").filter((a)=>(a)).map((a)=>(parseInt(a)));
var pc = 0;
var i = 0;
while(offsets[pc] != null){
i++;
var oldpc = pc;
pc += offsets[pc];
offsets[oldpc]++
}
console.log(i);
+16
View File
@@ -0,0 +1,16 @@
var offsets = require("fs").readFileSync("input.txt").toString().split("\n").filter((a)=>(a)).map((a)=>(parseInt(a)));
var pc = 0;
var i = 0;
while(offsets[pc] != null){
i++;
var oldpc = pc;
pc += offsets[pc];
if(offsets[oldpc] >= 3){
offsets[oldpc]--;
}
else{
offsets[oldpc]++
}
}
console.log(i);