aoc-2023/day_12/solve.ts

15 lines
582 B
TypeScript
Raw Normal View History

2024-12-09 22:41:02 +09:00
import { Solver, State } from "./solver.ts";
const input = await Deno.readTextFile("input.txt");
const lines = input.split("\n").map(x => x.trim()).filter(x => x.length > 0);
const datas = lines.map(x => {
const [statesStr, groupsStr] = x.split(" ");
return { state: statesStr.split(""), group: groupsStr.split(",").map(x => parseInt(x)) };
})
const ways = datas.map(data => {
const ret = new Solver(data.state as State[], data.group).solve(0, 0);
console.log(data.state.join(""), data.group, ret);
return ret;
});
console.log(ways.reduce((a, b) => a + b, 0));