Skip to content

Instantly share code, notes, and snippets.

@asimpson
Created December 6, 2017 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asimpson/5124e316065d572aee9f39fa8fc7d241 to your computer and use it in GitHub Desktop.
Save asimpson/5124e316065d572aee9f39fa8fc7d241 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const list = fs.readFileSync('./input.txt').toString().trim().split('\n');
const go = list => {
var moves = 0;
var position = 0;
for (; list[position] !== undefined; moves++) {
const pos = position + parseInt(list[position], 10);
list[position] = (parseInt(list[position], 10) + 1).toString();
position = pos;
}
console.log(moves);
};
go(list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment