12 lines
346 B
JavaScript
12 lines
346 B
JavaScript
var input = require("fs").readFileSync("input.txt").toString();
|
|
var links = input.split("\n").filter((a)=>(a)).map((a)=>(a.split(" <-> ")[1].split(", ").map((b)=>(parseInt(b)))));
|
|
var attached = [];
|
|
function add(x){
|
|
if(attached.indexOf(x) == -1){
|
|
attached.push(x);
|
|
links[x].forEach((a)=>(add(a)));
|
|
}
|
|
}
|
|
add(0);
|
|
console.log(attached.length);
|