42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
|
import { LEFT, RIGHT, DOWN, UP } from "./lightMap.ts";
|
||
|
import { toLightMap, lightTrasport, clearLight, countPoweredTile } from "./lightMap.ts";
|
||
|
|
||
|
const input = await Deno.readTextFile("input.txt");
|
||
|
const lightMap = toLightMap(input);
|
||
|
const width = lightMap[0].length;
|
||
|
const height = lightMap.length;
|
||
|
|
||
|
const countPossibles = [];
|
||
|
for (let y = 0; y < height; y++) {
|
||
|
lightTrasport(lightMap, [0, y], RIGHT);
|
||
|
const count = countPoweredTile(lightMap);
|
||
|
console.log(`c(${0},${y}) =\t${count}`);
|
||
|
countPossibles.push(count);
|
||
|
clearLight(lightMap);
|
||
|
}
|
||
|
|
||
|
for (let y = 0; y < height; y++) {
|
||
|
lightTrasport(lightMap, [width - 1, y], LEFT);
|
||
|
const count = countPoweredTile(lightMap);
|
||
|
console.log(`c(${width - 1},${y}) =\t${count}`);
|
||
|
countPossibles.push(count);
|
||
|
clearLight(lightMap);
|
||
|
}
|
||
|
|
||
|
for (let x = 0; x < width; x++) {
|
||
|
lightTrasport(lightMap, [x, 0], DOWN);
|
||
|
const count = countPoweredTile(lightMap);
|
||
|
console.log(`c(${x},${0}) =\t${count}`);
|
||
|
countPossibles.push(count);
|
||
|
clearLight(lightMap);
|
||
|
}
|
||
|
|
||
|
for (let x = 0; x < width; x++) {
|
||
|
lightTrasport(lightMap, [x, height - 1], UP);
|
||
|
const count = countPoweredTile(lightMap);
|
||
|
console.log(`f(${x},${height - 1}) =\t${count}`);
|
||
|
countPossibles.push(count);
|
||
|
clearLight(lightMap);
|
||
|
}
|
||
|
|
||
|
console.log("max: ", Math.max(...countPossibles))
|