12 lines
250 B
JavaScript
12 lines
250 B
JavaScript
|
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);
|