16 lines
382 B
JavaScript
16 lines
382 B
JavaScript
|
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);
|