var input = require("fs").readFileSync("input.txt").toString().replace(/\r/g, ""); var devices = input.split("\n").filter((line)=>(line.indexOf("/dev/") != -1)).map((line)=>(line.match(/\/dev\/grid\/node-x([0-9]+)-y([0-9]+)[ ]+([0-9]+)T[ ]+([0-9]+)T[ ]+([0-9]+)T[ ]+([0-9]+)%/))).map((match)=>({ x: parseInt(match[1]), y: parseInt(match[2]), size: parseInt(match[3]), used: parseInt(match[4]), available: parseInt(match[5]), percentageUsed: parseInt(match[6]), })); devicesMap = devices.reduce((map, device)=>{ if(!map[device.y]){ map[device.y] = [] }; map[device.y][device.x] = device; return map; }, []); console.log(devicesMap.map((row)=>(row.map((device)=>(device.used + "/" + device.available)).join(","))).join("\n"));