aoc-2023/day_13/solve.ts

24 lines
669 B
TypeScript
Raw Permalink Normal View History

2024-12-09 22:41:02 +09:00
import { readData, Data, getBitsNumbers, getReflectionIndex, transpose } from "./solver.ts";
const input = await Deno.readTextFile("input.txt");
const maps = readData(input);
let verticalSum=0, horizontalSum = 0;
maps.forEach((map, index) => {
console.log("map", index);
const horizontal = map.map(x=> getBitsNumbers(x));
const vertical = transpose(map).map(x=> getBitsNumbers(x));
const hi = getReflectionIndex(horizontal);
const vi = getReflectionIndex(vertical);
if (hi > 0){
horizontalSum += hi;
}
if (vi > 0){
verticalSum += vi;
}
console.log(hi, vi);
});
console.log(horizontalSum * 100 + verticalSum);