Add solution day 15
This commit is contained in:
parent
3aa713288e
commit
65b0a425d2
21
day_15/example_1.txt
Normal file
21
day_15/example_1.txt
Normal file
@ -0,0 +1,21 @@
|
||||
##########
|
||||
#..O..O.O#
|
||||
#......O.#
|
||||
#.OO..O.O#
|
||||
#..O@..O.#
|
||||
#O#..O...#
|
||||
#O..O..O.#
|
||||
#.OO.O.OO#
|
||||
#....O...#
|
||||
##########
|
||||
|
||||
<vv>^<v^>v>^vv^v>v<>v^v<v<^vv<<<^><<><>>v<vvv<>^v^>^<<<><<v<<<v^vv^v>^
|
||||
vvv<<^>^v^^><<>>><>^<<><^vv^^<>vvv<>><^^v>^>vv<>v<<<<v<^v>^<^^>>>^<v<v
|
||||
><>vv>v^v^<>><>>>><^^>vv>v<^^^>>v^v^<^^>v^^>v^<^v>v<>>v^v^<v>v^^<^^vv<
|
||||
<<v<^>>^^^^>>>v^<>vvv^><v<<<>^^^vv^<vvv>^>v<^^^^v<>^>vvvv><>>v^<<^^^^^
|
||||
^><^><>>><>^^<<^^v>>><^<v>^<vv>>v>>>^v><>^v><<<<v>>v<v<v>vvv>^<><<>^><
|
||||
^>><>^v<><^vvv<^^<><v<<<<<><^v<<<><<<^^<v<^^^><^>>^<v^><<<^>>^v<v^v<v^
|
||||
>^>>^v>vv>^<<^v<>><<><<v<<v><>v<^vv<<<>^^v^>^^>>><<^v>>v^v><^^>>^<>vv^
|
||||
<><^^>^^^<><vvvvv^v<v<<>^v<v>v<<^><<><<><<<^^<<<^<<>><<><^^^>^^<>^>v<>
|
||||
^^>vv<^v^v<vv>^<><v<^v>^^^>>>^^vvv^>vvv<>>>^<^>>>>>^<<^v>^vvv<>^<><<v>
|
||||
v^^>>><<^^<>>^v^<v^vv<>v^<<>^<^v^v><^<<<><<^<v><v<>vv>>v><v^<vv<>v^<<^
|
10
day_15/example_2.txt
Normal file
10
day_15/example_2.txt
Normal file
@ -0,0 +1,10 @@
|
||||
########
|
||||
#..O.O.#
|
||||
##@.O..#
|
||||
#...O..#
|
||||
#.#.O..#
|
||||
#...O..#
|
||||
#......#
|
||||
########
|
||||
|
||||
<^^>>>vv<v>>v<<
|
9
day_15/example_3.txt
Normal file
9
day_15/example_3.txt
Normal file
@ -0,0 +1,9 @@
|
||||
#######
|
||||
#...#.#
|
||||
#.....#
|
||||
#..OO@#
|
||||
#..O..#
|
||||
#.....#
|
||||
#######
|
||||
|
||||
<vv<<^^<<^^
|
71
day_15/input.txt
Normal file
71
day_15/input.txt
Normal file
@ -0,0 +1,71 @@
|
||||
##################################################
|
||||
#OO#..O#......#...O.O..##..O.....O...O.......#...#
|
||||
#...O.O...O.OO.O....O...O.#...O...OOO#O..#.#..O.##
|
||||
#..O.O.....O.....O..OOO.#OOO...O....#.#.OO....OO.#
|
||||
#.......OO#....OOOOO#...O..#...#..OO#O.....O.#...#
|
||||
#......O..O....O....O......O..O....O.O#...#......#
|
||||
#...OOO..O..O..#..#.....#O.O..O.....##..#..O.OO#.#
|
||||
#..#O.O..OOO..OOO..O.O.OO......OOO.........O..O.O#
|
||||
#...O.#...O##O....#O..OO.O..O.O.O....O....#......#
|
||||
#.....O.O..OO.O.....O......O.#O...OO.O......O.OO##
|
||||
#....O.#O.....O...OO.O.OO......O.O.O..........#O.#
|
||||
#...O..O.#.O..##.O.OO.O.O.O.....OO.....O.O...O.O.#
|
||||
#.........O#.O.O...O.#..O...........O#..#.#OO#...#
|
||||
#O.#..O.#.O....O....O.O..#.O..O.OOO.O..##..O.....#
|
||||
#..O..OO....#..O..O........#.OO...#...O##..O....O#
|
||||
#..O...#.#O#..O.O..O.#.OO.#.##O.O.#O..OO.O.OO..O.#
|
||||
#O#..O..#.#O..O.....O.O.O..O..#O....O..OO.......##
|
||||
#..OO..................##.#.O...O......O.O..OOOOO#
|
||||
#....OO....OOO........#O....#O#.##O.O..OO.O#.....#
|
||||
#..#.......O.....#....O..#........OOO.#.O.O..#.###
|
||||
#..O........OOOOO......O.O#..O.OO#....#....##....#
|
||||
#.OO.#....O..#O......O.O....#...O...#..OOO.....#O#
|
||||
#.O.......#O...OOO.OO.O..OOO...OOO.##...O#OOO.O..#
|
||||
#O##O..O..#......OO.OOO.#OO....OO....O...OO.#.O..#
|
||||
#.#.O.....O..O.O..O..OO.@.O.O......O.....#O##O..O#
|
||||
#....OO.........O.....OO...#..#...O..#O#.....OOOO#
|
||||
#.O.O#.O.......O#...OOO....O.O.O#.O.O..O.........#
|
||||
#O..O.OO...O..OO...O.OOOOO..OOOOO.....#..#..O.O..#
|
||||
##.O....OO..##...OO...O....#.O....O#.##OO.O#..O..#
|
||||
#.O.O.OO.....O.#.O.#.....OOO.O...O...O#.O.....O..#
|
||||
#.....O..##O#.....#.O...O....OOO.#O.....O.O.....O#
|
||||
#...O..O#.O..O.##..O...O....O.#....OO...###O....##
|
||||
#O...O.O....O.OOO...##.O.#...OO.O.......O.....O#.#
|
||||
#..O..O..O.O..##O..#..O...#.....O.......OO...#.O.#
|
||||
#O##..O.O.....O.#O#......OOO.......OOO...O.O#..O.#
|
||||
#..O.O.##O..O....O.OO.O......O.O.OOO.O#..O.O.O#OO#
|
||||
#...#..OO#O.#O.....O.O.O...O.O.....O..OO#....O#.O#
|
||||
#O......O.O...#.O....O...#O.#......O...#.O#O...O.#
|
||||
#......O.#...OO...O.O...O..........O......O..O.O.#
|
||||
#..OO.O.O#..O.O....O.O.O..O..O.#..#.#.#O......OO.#
|
||||
#.O#..O....O..OO..O....#....O..OOOO.O.#..O.......#
|
||||
#O.........#.O...##..O..#...O...OO...O...O......O#
|
||||
#O.O........OOO..O..........O...O#.O..O.O...O....#
|
||||
#O.O#..O.O..O.OO..OO...........O...OO......OO.#.O#
|
||||
#O##..........#..#.O..#.OO.O...........OO....O..O#
|
||||
#....O....#OO..#O#..O.......O..O.O.O..O#.O.O..O..#
|
||||
#............O.#.O.O.OO......OO.O.O.O.O..#O.OO.O.#
|
||||
#O.OO......O.#..OO...O.....O.#..O..OO..#.#OO..O..#
|
||||
#.......##.OO....O.OO.#..O.O.O..OO..........OO..O#
|
||||
##################################################
|
||||
|
||||
vvvv<><v<>vv<>^vv>>>^<v>v>^>><>^<^v<>v>>><^><^v<>^v><<<><<>v<vv>v>^v^v<^vvv>>vv^>^vv^^v<^v^>^<^><<v^<<<^>v<^^>^^<><>><<<^^v><>^^^<<vv>^^^^<v<vv^>><v<^^vv^<>vv<v<^v<v<>^>^<<><vv><<^^<v^>vv<^<<v<v>>^>v><>^^v<>>^vvv^^^^<>vv>v^^<>><^>v<^<>^^^^v<>>v>^v^<v>^>>v<vv^^>>>^>><^vv>vv^v<v<v<^>><><v>>^>>>v<>^^>^^<<v<vv<<<v<v^>^<><<<>vvv^<vv><^^<v<<<<^<v<v<>^^<^^<^><>^>^<<<<v<>>>><>^<^^><>>>^^><v>v<<^>><<>^<v<<^<^v^>v^>>>vv^vv^<vv^>vv^>v^>v^v>v<^v><^^vv^<<>^v<<^v><<><<<v^><v^^vvv^>^^>^vvvv>^>v>^^<^v>><>^>^vv<<vvvv<^^^<<vv^v^>>><>>v>>>v>>^<^v^>v^^><vv^^vvv<^v>^>><>v><vv<^^>^<><v^<<v<^><v><^<>>>^v>>v><><>v^^>^^<>^<v<<vv<<><><<^^v^>vvv^>v><^^^^^><vvv<<v>^v^^v<><<^<>v^^^<<vv<<^v>v^<>^^>v^vv<v^<<vv<<<>v^>v<>vvvv>vv^^<>v^><^<^<^^<>^^v<<v^vv>>^>>>v<<>v>>^<^<vv<^>^^^^v>^^^v^>>>>vvv^vv>vv^^>^v>v><<v^<>^>>>>v<^vv<^v^v^^v^><v<v^v>^>>vv<<<^^^<>v<^>>>^>v<^>^^<<v^<v<<<>>^<>><^<v^>vv<>v>>><>v^<^v>^<<^<vvv>v<>v<v<<<>vv^vvv^<^v^>vv>^<<^<>v^<^^^<v>^^v<<v>v^<<vvv^>>^<v<^^>>>^^<<<vv<^^^^<>><v>><<>v^v<^>>>^<<>^^<>>^v<<>
|
||||
v^>><v><vv^^^><v^<><^^>>><<^vv<<<^vv>vvv<v><^v<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^vv<><<<>><<v<><v<v<><v^^^>v<><>^<^vvv^>vv^^v<>v<>^<^<>><><^>>>v<<<>vv<>>>^^vvv>^<<<>^v<v<vv>v<v>vv>>^<^><>^>>^vvv<>v><^^v>^^<<>><<vv^>^v<>^v<<<>^^^>>>^>v<<<<^^><<>v^>>><>>^><^^><><^<^<<v><vv<<v><<<<>^>v>^<><>vvvv^><^^^>^>>><<>vv>v>>>^v<>vvv<<^>>>^v>>vv><v<^^vv^>^>^^>^>^vv<^^^>v<v^><^>>>^^>>v<^v>v<<v>vv><v<^v^^>><>^v>>><^vv><<^^v>^>v>vv^^^<<>v<v>^^>^<>>v^v>^>^>v^>^<v>^><^^>^v^<<v<v<^^v<v<<v^>vv>>^^v>>^>^vv<>><>^^>v>v<vvv<>>^<v^v^>v^<><vvv^v<>>v><>>>>v>>v>><><v<v^<v<<<>vvv<^v<>><^
|
105
day_15/solve_1.ts
Normal file
105
day_15/solve_1.ts
Normal file
@ -0,0 +1,105 @@
|
||||
export type Map = string[][];
|
||||
|
||||
export type Move = "^" | "v" | "<" | ">";
|
||||
|
||||
export async function readData(path: string): Promise<{
|
||||
map: Map,
|
||||
moves: Move[]
|
||||
}> {
|
||||
const text = await Deno.readTextFile(path);
|
||||
const [
|
||||
map,
|
||||
moves
|
||||
] = text.split("\n\n");
|
||||
return {
|
||||
map: map.split("\n").map((line) => line.split("")),
|
||||
moves: moves.split("\n").join("").split("").map((move) => move as Move)
|
||||
};
|
||||
}
|
||||
|
||||
export function displayMap(map: Map): string {
|
||||
return map.map((line) => line.join("")).join("\n");
|
||||
}
|
||||
|
||||
export function foreachMap(map: Map, callback: (value: string, x: number, y: number) => void): void {
|
||||
map.forEach((line, y) => {
|
||||
line.forEach((value, x) => {
|
||||
callback(value, x, y);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const dirToDelta = {
|
||||
"^": [0, -1],
|
||||
"v": [0, 1],
|
||||
"<": [-1, 0],
|
||||
">": [1, 0]
|
||||
}
|
||||
|
||||
export function stepRobot(map: Map, robot: {x: number, y: number}, move: Move): void {
|
||||
const {x, y} = robot;
|
||||
const [dx, dy] = dirToDelta[move];
|
||||
// Check if the robot can move
|
||||
|
||||
// like socoban, @ is the robot, # is a wall, . is a free space, O is a box
|
||||
// multiple boxes can be pushed at the same time
|
||||
let nextX = x;
|
||||
let nextY = y;
|
||||
while (true) {
|
||||
nextX += dx;
|
||||
nextY += dy;
|
||||
const nextValue = map[nextY][nextX];
|
||||
if (nextValue === "#") {
|
||||
// The robot can't move
|
||||
return;
|
||||
}
|
||||
else if (nextValue === ".") {
|
||||
break;
|
||||
}
|
||||
if (nextValue === "O") {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let prevX = nextX;
|
||||
let prevY = nextY;
|
||||
// move the boxes
|
||||
while (prevX !== x || prevY !== y) {
|
||||
map[prevY][prevX] = map[prevY - dy][prevX - dx];
|
||||
prevX -= dx;
|
||||
prevY -= dy;
|
||||
}
|
||||
// move the robot
|
||||
map[y][x] = ".";
|
||||
robot.x = x + dx;
|
||||
robot.y = y + dy;
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
const {map, moves} = await readData("input.txt");
|
||||
let robot = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
foreachMap(map, (value, x, y) => {
|
||||
if (value === "@") {
|
||||
robot = {
|
||||
x,
|
||||
y
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log("Robot", robot);
|
||||
console.log(displayMap(map));
|
||||
moves.forEach((move) => {
|
||||
// console.log("Move", move, ":");
|
||||
stepRobot(map, robot, move);
|
||||
// console.log(displayMap(map));
|
||||
});
|
||||
let sum = 0;
|
||||
foreachMap(map, (value, x, y) => {
|
||||
if (value === "O") {
|
||||
sum += x + y * 100;
|
||||
}
|
||||
});
|
||||
console.log("Sum", sum);
|
||||
}
|
187
day_15/solve_2.ts
Normal file
187
day_15/solve_2.ts
Normal file
@ -0,0 +1,187 @@
|
||||
import { displayMap, foreachMap, Map, Move, readData } from "./solve_1.ts";
|
||||
|
||||
const extendingTranslation = {
|
||||
"#": "##",
|
||||
".": "..",
|
||||
"O": "[]",
|
||||
"@": "@.",
|
||||
};
|
||||
|
||||
function extendMap(map: Map) {
|
||||
const extendedMap = map.map((row) => {
|
||||
return row.map((value) => {
|
||||
const v = extendingTranslation[
|
||||
value as keyof typeof extendingTranslation
|
||||
];
|
||||
if (v) {
|
||||
return v;
|
||||
}
|
||||
throw new Error("Invalid value");
|
||||
}).join("").split("");
|
||||
});
|
||||
return extendedMap;
|
||||
}
|
||||
|
||||
function getHugeBoxPos(map: Map, boxPos: [number, number]): [number, number] {
|
||||
const [x, y] = boxPos;
|
||||
const anyBracket = map[y][x];
|
||||
if (anyBracket === "]") {
|
||||
return [x - 1, y];
|
||||
}
|
||||
if (anyBracket === "[") {
|
||||
return [x, y];
|
||||
}
|
||||
throw new Error("Not a huge box");
|
||||
}
|
||||
|
||||
function IsMovableHugeBox(
|
||||
map: Map,
|
||||
boxPos: [number, number],
|
||||
move: Move,
|
||||
): boolean {
|
||||
const [x, y] = getHugeBoxPos(map, boxPos);
|
||||
if (move === "^" || move === "v") {
|
||||
const dy = move === "^" ? -1 : 1;
|
||||
if (map[y + dy][x] === "#" || map[y + dy][x + 1] === "#") {
|
||||
return false;
|
||||
}
|
||||
if (map[y + dy][x] === "." && map[y + dy][x + 1] === ".") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (map[y + dy][x] === "]") {
|
||||
const success = IsMovableHugeBox(map, [x, y + dy], move);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
} else if (map[y + dy][x] === "[") {
|
||||
const success = IsMovableHugeBox(map, [x, y + dy], move);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (map[y + dy][x + 1] === "[") {
|
||||
const success = IsMovableHugeBox(map, [x + 1, y + dy], move);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
const dx = move === "<" ? -1 : 2;
|
||||
const [nx, ny] = [x + dx, y];
|
||||
if (map[ny][nx] === "#") {
|
||||
return false;
|
||||
}
|
||||
if (map[ny][nx] === ".") {
|
||||
return true;
|
||||
}
|
||||
return IsMovableHugeBox(map, [nx, ny], move);
|
||||
}
|
||||
}
|
||||
|
||||
function pushHugeBox(map: Map, boxPos: [number, number], move: Move) {
|
||||
const [x, y] = getHugeBoxPos(map, boxPos);
|
||||
if (move === "^" || move === "v") {
|
||||
const dy = move === "^" ? -1 : 1;
|
||||
if (map[y + dy][x] === "]") {
|
||||
pushHugeBox(map, [x, y + dy], move);
|
||||
} else if (map[y + dy][x] === "[") {
|
||||
pushHugeBox(map, [x, y + dy], move);
|
||||
}
|
||||
if (map[y + dy][x + 1] === "[") {
|
||||
pushHugeBox(map, [x + 1, y + dy], move);
|
||||
}
|
||||
if (map[y + dy][x] === "." && map[y + dy][x + 1] === ".") {
|
||||
map[y][x] = ".";
|
||||
map[y][x + 1] = ".";
|
||||
map[y + dy][x] = "[";
|
||||
map[y + dy][x + 1] = "]";
|
||||
return;
|
||||
} else {
|
||||
throw new Error("can't push the box");
|
||||
}
|
||||
} else {
|
||||
if (map[y][x - 1] === "]" && move === "<") {
|
||||
pushHugeBox(map, [x - 1, y], move);
|
||||
}
|
||||
if (map[y][x + 2] === "[" && move === ">") {
|
||||
pushHugeBox(map, [x + 2, y], move);
|
||||
}
|
||||
const dx = move === "<" ? -1 : 1;
|
||||
const nx = x + dx;
|
||||
if (
|
||||
(move === "<" && map[y][nx] === ".") ||
|
||||
(move === ">" && map[y][nx + 1] === ".")
|
||||
) {
|
||||
map[y][x] = ".";
|
||||
map[y][x + 1] = ".";
|
||||
map[y][nx] = "[";
|
||||
map[y][nx + 1] = "]";
|
||||
return;
|
||||
} else {
|
||||
throw new Error("can't push the box");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stepRobot(map: Map, robot: { x: number; y: number }, move: Move) {
|
||||
const { x, y } = robot;
|
||||
const dx = move === "<" ? -1 : move === ">" ? 1 : 0;
|
||||
const dy = move === "^" ? -1 : move === "v" ? 1 : 0;
|
||||
const nx = x + dx;
|
||||
const ny = y + dy;
|
||||
if (map[ny][nx] === "#") {
|
||||
return;
|
||||
}
|
||||
if (map[ny][nx] === "[" || map[ny][nx] === "]") {
|
||||
const [hx, hy] = getHugeBoxPos(map, [nx, ny]);
|
||||
if (IsMovableHugeBox(map, [hx, hy], move)) {
|
||||
pushHugeBox(map, [hx, hy], move);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
map[y][x] = ".";
|
||||
map[ny][nx] = "@";
|
||||
robot.x = nx;
|
||||
robot.y = ny;
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
let { map, moves } = await readData("input.txt");
|
||||
console.log(displayMap(map));
|
||||
map = extendMap(map);
|
||||
let robot = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
foreachMap(map, (value, x, y) => {
|
||||
if (value === "@") {
|
||||
robot = {
|
||||
x,
|
||||
y,
|
||||
};
|
||||
}
|
||||
});
|
||||
console.log("Robot", robot);
|
||||
console.log(displayMap(map));
|
||||
moves.forEach((move) => {
|
||||
// console.log("Move", move, ":");
|
||||
try {
|
||||
stepRobot(map, robot, move);
|
||||
} catch (_e) {
|
||||
console.log("Move", move, ":");
|
||||
console.log(displayMap(map));
|
||||
}
|
||||
// console.log(displayMap(map));
|
||||
});
|
||||
let sum = 0;
|
||||
foreachMap(map, (value, x, y) => {
|
||||
if (value === "[") {
|
||||
sum += x + y * 100;
|
||||
}
|
||||
});
|
||||
console.log(displayMap(map));
|
||||
console.log("Sum", sum);
|
||||
}
|
Loading…
Reference in New Issue
Block a user