this repo has no description

Solve D09P01

modamo 11031bf5 2157a31c

Changed files
+40
day09
+40
day09/part1.ts
··· 1 + import { readFileSync } from "fs"; 2 + 3 + let [gridRows, gridCols] = [-Infinity, -Infinity]; 4 + 5 + const tiles = readFileSync("./input.txt", "utf8") 6 + .split(/\n/) 7 + .map((line) => line.split(",").map(Number)) 8 + .map((coordinate) => { 9 + const [c, r] = coordinate; 10 + 11 + gridCols = Math.max(c + 1 + 2, gridCols); 12 + gridRows = Math.max(r + 1, gridRows); 13 + 14 + return { c, r }; 15 + }); 16 + 17 + let largestArea = -Infinity; 18 + 19 + for (let i = 0; i < tiles.length; i++) { 20 + for (let j = i + 1; j < tiles.length; j++) { 21 + largestArea = Math.max( 22 + largestArea, 23 + (Math.abs(tiles[i].c - tiles[j].c) + 1) * 24 + (Math.abs(tiles[i].r - tiles[j].r) + 1) 25 + ); 26 + } 27 + } 28 + 29 + console.log(largestArea); 30 + 31 + const grid = [ 32 + ...new Array(gridRows).fill(null).map(() => new Array(gridCols).fill(".")), 33 + ...new Array(gridCols).fill(".") 34 + ]; 35 + 36 + for (const tile of tiles) { 37 + grid[tile.r][tile.c] = "#"; 38 + } 39 + 40 + // console.log(grid);