var input = require("fs").readFileSync("input.txt").toString(); var inputjson = "[{" + input.replace(/([a-z])=/g, "]").replace(/\n/g, "},\n{").slice(0,-3) + "]"; var objects = JSON.parse(inputjson); for(var i = 0; i < 10000; i++){ objects = objects.map(o=>{ o.v = o.v.map((v,x)=>(v + o.a[x])); o.p = o.p.map((p,x)=>(p + o.v[x])); return o; }); var locations = objects.map(o=>(o.p)); var locationsStr = locations.map((a)=>(a.join(","))); objects = objects.filter((a)=>(locationsStr.filter((b)=>(b==a.p.join(","))).length == 1)); console.log(objects.length); }