adventofcode-2017/day07/part1.js

16 lines
382 B
JavaScript
Raw Normal View History

2017-12-07 15:07:07 +00:00
var lines = require("fs").readFileSync("input.txt").toString().split("\n").filter((a)=>(a));
var top = lines[0].split(" ")[0];
var oldtop = "";
while(oldtop != top){
oldtop = top;
for(var line of lines){
console.log(line);
if(line.indexOf("->") != -1){
if(line.split(" -> ")[1].split(", ").indexOf(top) != -1){
top = line.split(" ")[0];
}
}
}
}
console.log(top);