day 4,5,6
This commit is contained in:
1090
day05/input.txt
Normal file
1090
day05/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
11
day05/part1.js
Normal file
11
day05/part1.js
Normal 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
day05/part2.js
Normal file
16
day05/part2.js
Normal 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);
|
Reference in New Issue
Block a user