adventofcode-2017/day05/part1.js

12 lines
250 B
JavaScript
Raw Normal View History

2017-12-06 13:40:43 +00:00
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);