Compare commits
15 Commits
82e934b690
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2954c15705 | |||
| 534075f543 | |||
| 23ec60cde9 | |||
| b19fc90241 | |||
| f0bd46a65a | |||
| ecfe1aad35 | |||
| 5969abf458 | |||
| 26be46cdf3 | |||
| 79f5812001 | |||
| 3f5b7b4dc6 | |||
| e10ed8df26 | |||
| 7076b2d40c | |||
| dd6f6cffcf | |||
| d04d200024 | |||
| c667a2f72a |
23
README.md
23
README.md
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
[Advent of Code](https://adventofcode.com/) problems of 2025.
|
[Advent of Code](https://adventofcode.com/) problems of 2025.
|
||||||
|
|
||||||
|
### Progress
|
||||||
|
|
||||||
| Day | Name | Part 1 | Part 2 |
|
| Day | Name | Part 1 | Part 2 |
|
||||||
| :-: | :------------------ | :----: | :----: |
|
| :-: | :------------------ | :----: | :----: |
|
||||||
| 1 | Secret Entrance | ⭐ | ⭐ |
|
| 1 | Secret Entrance | ⭐ | ⭐ |
|
||||||
@@ -10,5 +12,22 @@
|
|||||||
| 4 | Printing Department | ⭐ | ⭐ |
|
| 4 | Printing Department | ⭐ | ⭐ |
|
||||||
| 5 | Cafeteria | ⭐ | ⭐ |
|
| 5 | Cafeteria | ⭐ | ⭐ |
|
||||||
| 6 | Trash Compactor | ⭐ | ⭐ |
|
| 6 | Trash Compactor | ⭐ | ⭐ |
|
||||||
| 7 | Laboratories | ⭐ | |
|
| 7 | Laboratories | ⭐ | ⏱️ |
|
||||||
| 8 | Playground | | |
|
| 8 | Playground | ⭐ | ⭐ |
|
||||||
|
| 9 | Movie Theater | ⭐ | 🌓 |
|
||||||
|
| 10 | Factory | ⭐ | ⏱️ |
|
||||||
|
| 11 | Reactor | ⭐ | |
|
||||||
|
| 12 | Christmas Tree Farm | | |
|
||||||
|
|
||||||
|
### Symbols
|
||||||
|
|
||||||
|
- 🌓 Completed with test input but some corner-case left on real input.
|
||||||
|
- ⏱️ Completed with test input but to slow to complete with real input.
|
||||||
|
- ⭐ All done.
|
||||||
|
|
||||||
|
## Brain made
|
||||||
|
|
||||||
|
1. I don't hate AIs,
|
||||||
|
2. I love humans!
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
22
src/__tests__/day_10_test.ts
Normal file
22
src/__tests__/day_10_test.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { assertEquals } from "@std/assert";
|
||||||
|
import {
|
||||||
|
count_min_button_presses,
|
||||||
|
count_min_button_presses_joltage,
|
||||||
|
read_machine_manuals,
|
||||||
|
} from "../exercises/day_10.ts";
|
||||||
|
|
||||||
|
Deno.test("Day 10 - A", async () => {
|
||||||
|
const manual_list = await read_machine_manuals(
|
||||||
|
"src/exercises/assets/day_10_test_input.txt",
|
||||||
|
);
|
||||||
|
const result = count_min_button_presses(manual_list);
|
||||||
|
assertEquals(result, 7);
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("Day 10 - B", async () => {
|
||||||
|
const manual_list = await read_machine_manuals(
|
||||||
|
"src/exercises/assets/day_10_test_input.txt",
|
||||||
|
);
|
||||||
|
const result = count_min_button_presses_joltage(manual_list);
|
||||||
|
assertEquals(result, 33);
|
||||||
|
});
|
||||||
10
src/__tests__/day_11_test.ts
Normal file
10
src/__tests__/day_11_test.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { assertEquals } from "@std/assert";
|
||||||
|
import { count_all_out_paths, read_device_list } from "../exercises/day_11.ts";
|
||||||
|
|
||||||
|
Deno.test("Day 11 - A", async () => {
|
||||||
|
const input_list = await read_device_list(
|
||||||
|
"src/exercises/assets/day_11_test_input.txt",
|
||||||
|
);
|
||||||
|
const result = count_all_out_paths(input_list, "you");
|
||||||
|
assertEquals(result, 5);
|
||||||
|
});
|
||||||
7
src/__tests__/day_12_test.ts
Normal file
7
src/__tests__/day_12_test.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { read_situation_summary } from "../exercises/day_12.ts";
|
||||||
|
|
||||||
|
Deno.test("Day 12 - A", async () => {
|
||||||
|
const summary = await read_situation_summary(
|
||||||
|
"src/exercises/assets/day_12_test_input.txt",
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { assertEquals } from "@std/assert";
|
import { assertEquals } from "@std/assert";
|
||||||
import {
|
import {
|
||||||
|
get_last_pairing_mul,
|
||||||
get_three_largest_pairings_mul,
|
get_three_largest_pairings_mul,
|
||||||
read_junction_box_3d_positions,
|
read_junction_box_3d_positions,
|
||||||
} from "../exercises/day_8.ts";
|
} from "../exercises/day_8.ts";
|
||||||
@@ -11,3 +12,11 @@ Deno.test("Day 8 - A", async () => {
|
|||||||
const result = get_three_largest_pairings_mul(junction_boxes_coords, 10);
|
const result = get_three_largest_pairings_mul(junction_boxes_coords, 10);
|
||||||
assertEquals(result, 40);
|
assertEquals(result, 40);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("Day 8 - B", async () => {
|
||||||
|
const junction_boxes_coords = await read_junction_box_3d_positions(
|
||||||
|
"src/exercises/assets/day_8_test_input.txt",
|
||||||
|
);
|
||||||
|
const result = get_last_pairing_mul(junction_boxes_coords);
|
||||||
|
assertEquals(result, 25272);
|
||||||
|
});
|
||||||
|
|||||||
22
src/__tests__/day_9_test.ts
Normal file
22
src/__tests__/day_9_test.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { assertEquals } from "@std/assert";
|
||||||
|
import {
|
||||||
|
get_largest_area,
|
||||||
|
get_largest_green_area,
|
||||||
|
read_tile_floor,
|
||||||
|
} from "../exercises/day_9.ts";
|
||||||
|
|
||||||
|
Deno.test("Day 9 - A", async () => {
|
||||||
|
const floor = await read_tile_floor(
|
||||||
|
"src/exercises/assets/day_9_test_input.txt",
|
||||||
|
);
|
||||||
|
const result = get_largest_area(floor);
|
||||||
|
assertEquals(result, 50);
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("Day 9 - B", async () => {
|
||||||
|
const floor = await read_tile_floor(
|
||||||
|
"src/exercises/assets/day_9_test_input.txt",
|
||||||
|
);
|
||||||
|
const result = get_largest_green_area(floor);
|
||||||
|
assertEquals(result, 24);
|
||||||
|
});
|
||||||
177
src/exercises/assets/day_10_input.txt
Normal file
177
src/exercises/assets/day_10_input.txt
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
[...#...] (0,2,3,6) (0,1,4,6) (1,3,4,5) (1,2,4,6) (0,2,3,4,5) (2,3,6) (1,2) (2,3,4,5,6) {37,24,84,71,44,32,71}
|
||||||
|
[...##.] (0,3,4) (0,1,2,5) (0,1,3,4,5) (3,4) {53,34,17,42,42,34}
|
||||||
|
[###.] (1,3) (0,1,2) {4,13,4,9}
|
||||||
|
[.#.....] (0,1,6) (0,2,4) (1,3,4,6) (0,1,3,5) (4,5) {219,37,194,30,211,23,19}
|
||||||
|
[...##] (1,2) (0,2,3) (0,3) (1,3) (2,3,4) {10,20,23,37,14}
|
||||||
|
[#.##] (1,3) (2) (0,1,2) (2,3) {16,26,38,24}
|
||||||
|
[#...] (1,3) (0,1) (0,3) (1) (2,3) {2,13,11,15}
|
||||||
|
[.###.#.] (0,3,6) (0,1,2,5,6) (1,2,3,4,5) (0,1,2,3,4,5) (0,1,4,5) (0,4,6) {76,41,23,27,48,41,50}
|
||||||
|
[#...#..###] (2,3,5,6,7,8,9) (0,4,6,7,8,9) (1,7,8) (0,1,2,8) (0,1,2,3,4,5,6,9) (0,2,3,4,5,7) (1,6,8) (1,6,9) {56,71,48,29,37,29,50,54,76,31}
|
||||||
|
[####...] (0,1,2,3,4,6) (1,2,4) (1,3,5) (0,2,5) (4,6) (0,1,4,5,6) (3,5,6) (3) (0,1,2,5) {32,56,31,49,53,50,48}
|
||||||
|
[#...#.##] (0,4,6,7) (0,3,5,6) (0,1,3,4) (0,1,2,5,6,7) (0,1,2,5,7) (0,2,3,4,5,6) {202,164,169,27,19,189,185,175}
|
||||||
|
[##....#.#] (2,3,8) (3,4,7) (1) (1,2,3,5,6,8) (5,8) (0,1,5,6,8) (4,6,7,8) (0,3,4,5,7,8) {15,17,16,20,15,21,27,15,45}
|
||||||
|
[##.#] (0,1,2) (0,1) (1,3) (2,3) (0,2) {176,12,167,3}
|
||||||
|
[....#....#] (0,3,6) (1,3,4) (3,4,5,9) (0,1,3,5,6,7,8,9) (1,2,3,4,6,8,9) (1,2,3,4,6,7,8,9) (2,5) (4,5,6,7) {19,29,5,35,36,44,41,38,19,23}
|
||||||
|
[####.##] (2,4) (0,1,6) (0,1,2,3,6) (1,2,4) (0,2,4,5,6) {36,207,217,13,204,13,36}
|
||||||
|
[#.#..##.] (0,1,2,3,4,5) (0,1,6,7) (5,7) (2,3,5,7) (2) (0,1,4) (2,3,4) (4,5) (0,2,3,4,5,7) {62,44,46,37,54,48,19,45}
|
||||||
|
[#.#.#.] (0,2,4) (1,3,4,5) (2) (1,2,3,4,5) {2,21,31,21,23,21}
|
||||||
|
[#...##..#] (0,3,4,7,8) (0,1,2,3,4,5,7) (2,3,4,6,7,8) (4,6,7) (6,7) (0,1,2,3,4,5,8) (2,4,5,6,7) (1,2,4,5,6) {46,38,60,60,78,46,48,75,41}
|
||||||
|
[..##.##] (2,4) (3,4) (2,4,5) (2,3,5,6) (0,1,2,3,6) (0,1,6) {32,32,57,38,49,24,37}
|
||||||
|
[####.####.] (0,1,2,3,5,6,7,8) (0,1,3,4,6,8) (1,3) (0,1,3,4,5,6,7) (0,2,3,4,5,8) (0,3,4,5) (2,7) (1,3,4,7,8,9) (0,1,2,4,6,9) (0,1,2,4,5,6,7,8,9) {48,51,33,56,55,42,32,53,36,25}
|
||||||
|
[#.....] (0,1,2,4,5) (0,1,3,4) (1,2,3) (3,4,5) (0,3,4) (0,2,4,5) {56,38,35,48,73,47}
|
||||||
|
[#.###] (0,1,2) (0,1,3) (0,2,3) (0,2,3,4) (2,3,4) {24,14,24,24,16}
|
||||||
|
[#.##.#..##] (1,2,6,7,8) (0,1,2,4,5,6,8,9) (0,1,2,3,5,6,7,8,9) (0,1,2,3,6,7,8,9) (0,2,4,8) (0,1,2,3,4,5,6,7,9) (2,3,4,7,8) (0,3,4,5,7,8) {94,71,110,75,83,57,71,84,112,62}
|
||||||
|
[###..####] (2,3) (3,4,5,7,8) (3,4) (1,4) (2,3,4,5,6,7,8) (2,3,4,6,7,8) (0,1,3,5,7) (0,3,5,6,7) (1,3,5,6,7,8) (0,1,2,4,5,7,8) (1,2,5,8) {44,61,49,85,75,93,48,89,72}
|
||||||
|
[.#..#.] (0,2) (5) (0,2,3,5) (2,4,5) (1,4,5) (1,4) (0,2,3) (1,2,5) {25,167,41,18,161,196}
|
||||||
|
[#.##...] (0,4,5,6) (0,1,2,3,4,5) (3,5) (0,2,3,5,6) (0,3,4,5) (0,1) (2,3,4,5,6) (3,4,6) (0,4,6) {68,22,57,101,79,92,63}
|
||||||
|
[.###....#] (2) (0,3,7,8) (0,7,8) (1,8) (2,6,8) (0,3,5,6) (0,1,2,4,7) {151,19,28,36,14,20,34,131,136}
|
||||||
|
[######.] (1,3,5) (2,3,4,6) (2,4,5,6) (1,5,6) (0,1,3,5,6) (3,4) (0,1,5) (3,4,5) (0,1,2,3,5) {29,58,119,29,119,169,131}
|
||||||
|
[#.###.###] (1,3,5) (0,2,3,4,6,8) (0,2,3,4,5,6) (1,3,4,6,7,8) (1,2,4,5,6,7) (0,1,4,6,7) (0,3,4,5,7,8) (2,5) (1,2,3,4,6,7,8) (0,2,3,4,6,7,8) (3,5) {53,44,74,90,86,78,69,59,52}
|
||||||
|
[..#.#.#] (0,1,3,4,5,6) (1,2,4) (0,3,4) (1,6) (1,3,4,6) {31,59,13,44,57,18,46}
|
||||||
|
[...#..] (2,3,4,5) (1,2,4) (0,4) (1,2,3,4,5) (1,4) (2) (1,3,5) (0,4,5) {35,28,33,17,76,33}
|
||||||
|
[...##...##] (0,1,2,3,4,6,7,8,9) (2,3,4,5) (0,1,2,4,5,6,7,8) (0,3,5,6,7,8,9) (3,8,9) (0,2,3,4,9) (1,3,4,5,6,7,8,9) (0,1,5,6,7,8,9) (0,2,3,5,6,7) (5,8) (4,7) (0,1,7,8) {241,49,53,252,65,240,238,246,264,251}
|
||||||
|
[.##..#] (0,2,3,5) (0) (0,1,3) (1,2,4) (1,3) (0,1,2,4) {32,23,12,15,10,2}
|
||||||
|
[#####....#] (0,1,4,5,6,7,9) (1,2,3,9) (0,2,3,4,5,6,7,9) (2,4,5,6,8,9) (1,3,5,8) (0,2,3,4,6,7,8,9) (2,3,4,6,8,9) (2,3,8,9) (0,1,2,4,6,7,8,9) (3,5,8,9) (1,2,3,4,5,7,8,9) {39,52,92,86,82,78,73,48,110,114}
|
||||||
|
[######.##.] (2,3,4,5,6,7,8,9) (2,3,4,6,8) (7,8) (7) (3,7,9) (0,1,2,3,5,7,8) (6,7) (0,1,3,5,7,9) (2,4,5,6,9) (7,9) (0,1,2,4,6) (0,2,3,4,7,8) {32,13,71,65,69,47,69,88,54,62}
|
||||||
|
[.###......] (1,2,3) (1,2,5,7,9) (1,4,8,9) (2,3,4,5) (0,2,4,5,8) (2,4,8) (0,1,4,6,7,8) (0,6,9) {19,33,37,14,44,8,16,3,41,36}
|
||||||
|
[.#..#] (1,3) (0) (1,2,3,4) (3,4) (1,2,3) {11,26,22,42,33}
|
||||||
|
[.##..#] (2,3) (0,1,3,4) (1,3,4) (1,2,5) {20,33,9,24,24,9}
|
||||||
|
[##..##.] (1,5,6) (0,1,2,3) (0,5,6) (0,1,2,4) (2,3,4,5,6) (0,2,4,5) {19,19,20,19,12,33,32}
|
||||||
|
[.####] (1,3) (0,1,3) (1,4) (1,3,4) (1,2,3,4) (0,3,4) (0,2,4) {22,50,20,39,49}
|
||||||
|
[.#.#####] (1,5,6,7) (0,1,2,3,4,5) (1,2,5) (2,3) (2,3,4,5,6) (0,1,2,3,5,7) (0,2,3,4,5,7) (0,1,3,4,5) {58,68,63,82,57,92,34,44}
|
||||||
|
[..###.####] (0,1,3,7,9) (1,2,4,7,8) (0,1,2,5,7) (1,3,4,5,7,8,9) (0,1,5,6,7,8,9) (0,1,3,4,6,8,9) (1,8) (3,4,9) (0,1,4,5,6) (2,4,7) (2,3,5,6,7,8,9) (0,1,2,4,5,6,9) {27,44,21,21,34,36,30,28,30,32}
|
||||||
|
[.#.##.#..] (1,5,7,8) (0,2) (0,3,7,8) (0,1,2,4,5,6,7,8) (0,1,3,4,5,6,7) (4,5,8) (0,5,7) {46,33,31,9,33,55,17,48,58}
|
||||||
|
[##.######.] (0,1,3,4,5,6,7,8) (1,3,5,6,7) (0,3,4,5,6,7,9) (0,2,3,5,7,9) (0,1,7,8) (0,2,8,9) (2,7,8) (0,1,2,3,5,8,9) (4,5) {177,34,28,176,152,179,160,180,35,158}
|
||||||
|
[###..] (1,3,4) (0,4) (4) (0,2,3,4) (1,2) (2) (0,1,3) {32,22,20,19,31}
|
||||||
|
[.#.##] (0,1,4) (3,4) (1,2,3) (1,3,4) {173,191,7,25,191}
|
||||||
|
[#...###] (0,3,4,5,6) (0,1,3,4,5) (0,1,2,3,5) (1,3) (0,1) (0,2,3,4,6) (1,2,3) (3,4,6) (4) {34,42,16,67,64,23,31}
|
||||||
|
[.#.#..#..#] (0,2,3,4,5,7,8,9) (0,2,3,4,6,7,8,9) (1,3,6,9) (0,5,6,8,9) (1,2,3,4,9) (1,4,5,6,7,9) (0,1,2,3,5,7) (0,1,2,9) (0,1,2,3,4,6,7,8) (3,7) (0,1,2,4,5,7,8,9) {91,77,78,80,84,69,81,89,80,108}
|
||||||
|
[#....#.] (0,1,2) (1,4,5,6) (1,3,4,5) (2,3,5) (0,3,4,5,6) (0,2,6) (2,3,4,5,6) (1,2,3,4,5,6) {28,30,73,56,43,63,57}
|
||||||
|
[...###..#] (1,2,4,7,8) (0,1,4,8) (0,2,3,4,5,6,7,8) (2,3,5,6,7) (1,7) (0,4,5,7) (6,8) (0,4) (0,6) {198,54,44,24,210,25,32,64,54}
|
||||||
|
[....####] (1,3,4,5) (1,3,6) (1,4,5,7) (4,5,6,7) (0,1,3,4,5,6,7) (0,1,4,5,6,7) (0,1,2,3,5,6) {35,74,11,41,73,84,61,58}
|
||||||
|
[...#.###.] (0,2,3,4,7,8) (2,3,5,6) (0,1,3,4,6,7,8) (0,3,4,5,7) (0,3,4,5,7,8) (0,5) (0,1,2,5,6,7) (0,1,5,6,7,8) (0,2,3,5,6,7,8) {82,41,12,50,41,62,50,70,68}
|
||||||
|
[#....###.#] (1,2,4,5,6,7,8,9) (1,2,3,4,7) (4) (6,8,9) (0,2,3,4,6,7,9) (0,1,3,5,6) (0,3,4,5,6,8,9) (0,3,5,6,7,8,9) (2,4,7) (2,4,5,6) (4,8) (1,2,4,6,7,8,9) (2,5) {52,40,64,69,92,62,88,52,67,65}
|
||||||
|
[#.#..#.#] (0,2) (0,2,3,4,5,7) (0,4,5,6,7) (3,4,5) (0,1,3,4,5) (0,1,2,4,6,7) (1,4) (1,2,5,7) (3,4,7) (1,3) {63,63,42,53,91,59,25,46}
|
||||||
|
[##.###.###] (3,4,7,9) (0,2,3,4,6,7,9) (4,5,7,8,9) (0,4,5,6,7) (0,1,2,3,4,6) (0,1,3,4,5,7,8,9) (0,1,2) (3,4,5,6,7) (0,3,6,7,8,9) (0,2,3,4,5,7,9) (1,7) (0,1,2,3,4,5,7,8) (7,8) {84,63,53,88,96,67,55,104,39,48}
|
||||||
|
[.##..##..] (0,1,2,3,4,5,7) (0,5,8) (0,1,2,5,8) (0,1,3,4,7,8) (0,1,2,4,5,6,7) (0,1) (0,1,4,5,6,7,8) (2,3,5,6,7,8) (1,2,4,5,7,8) {171,173,65,59,167,180,138,187,170}
|
||||||
|
[.###.#..] (3,5,6,7) (3,5,7) (1,2,3,4,5,7) (0,1,3,4,5,7) (0,1,2) (0,1,3,4,6,7) (0,2,4) (0,3,4,6) {238,28,28,220,226,10,211,26}
|
||||||
|
[..##.] (0,1,2,3) (2,3) (1,4) {11,20,21,21,9}
|
||||||
|
[.###.#####] (0,4,5,6,7,8,9) (2,3,4,5,8,9) (1,2,4,5) (0,1,2,3,4,6,8,9) (1,2,3,5,6,7,8,9) (0,1,4,5,8,9) (0,2,3,4,5,6,7,9) (3,4,5,9) (1,2,3,4,5,6,7,8) {192,65,72,67,229,220,196,179,213,215}
|
||||||
|
[###..#.#] (2,3,5) (1,4) (1,2,5) (0,1,2,4,5,6) (0,4,6) (3,4) (0,1,2,5) (0,2,3,4,6,7) (2,4,6,7) (0,1,2,3,5,7) {73,48,232,50,216,55,206,190}
|
||||||
|
[.###..##] (0,1,3,4,5,6,7) (1,2,3,4,6,7) (0,3,4,5) (0,1,4,5,6) (0,2,3,4,6,7) (0,4,6,7) (2,3,6) (0,1,2,3,4,5) (0,7) (4,6) {49,29,39,54,62,33,53,27}
|
||||||
|
[####] (1,2) (2,3) (0,1,3) (3) (2) (0,1) {18,20,22,31}
|
||||||
|
[.......#] (0,1,3,4,5,7) (5) (0,2,3,4,5,6) (6) (2,3,4,5,7) (0,1,2,3,7) (0,2,4,6,7) (1,6) (0,1,2,4,5,6) {63,39,164,166,165,151,42,170}
|
||||||
|
[#.#.] (1,3) (1) (1,2) (0,1,2) (0,3) (3) {25,47,27,25}
|
||||||
|
[.###] (0,3) (2,3) (1,2,3) (1,3) {132,23,26,165}
|
||||||
|
[..#...] (0,3,4) (2) (1,2,3,5) (0,1,3,4,5) {19,9,17,25,19,9}
|
||||||
|
[##.#] (1,2,3) (0,1,3) (0,1,2) {123,138,15,138}
|
||||||
|
[..##...#.#] (0,1,3,4,6,8,9) (0,8,9) (0,2,4,5,7,8,9) (0,2,3,7) (2,3,5,8,9) (0,1,2,3,4,6,9) (0,3,4,6,8,9) (1,3,6,7,9) (1,2,3,8) (0,6,7,9) {57,57,53,74,43,19,50,39,53,77}
|
||||||
|
[.#.#..#.#] (1,3,4,5,6,7) (1,7) (2,8) (1,3,4,5,7,8) (0,1,2,4,5,6,7) (0,8) (3,5,8) (1,3,5,6) {8,23,4,17,3,19,6,19,21}
|
||||||
|
[...######.] (0,2,3,4,6,8,9) (1,3,9) (0,1,2,3,4,5,9) (0,2,4,6,7,9) (3,5) (0,4,5,8) (0,3,5,6,8) (1,2,3,5,6,7,8) {34,3,20,37,24,30,29,8,27,20}
|
||||||
|
[.#...] (0,2) (1,3) (2,3) (0,4) (2,4) (3) {19,5,152,10,155}
|
||||||
|
[##.##.#...] (2,4,6,7,8,9) (1,3,9) (2,4) (1,3,5,6) (0,2) (0,1,2,4,6,7,9) (1,6,8) (0,1,3,4,5,6,9) (0,2,3,4,5,6,8,9) (0,1,2,7,8) (2) {40,62,63,38,42,26,60,29,42,44}
|
||||||
|
[##.###.] (0,3,5,6) (0,1,3,4,5) (0,1,5) (0,3,4,6) (0,1,3,4,6) (0,2,3,5) (4,5) (1,2,5,6) (1,2,4) {50,28,22,34,27,47,21}
|
||||||
|
[.#.##..##] (3,5,7) (0,1,3) (1,2,5,6) (0,3,6,7,8) (4,6) (5,8) (3,8) (0,3,4,5) (1,2,3) (0,2,3,4,6,7,8) (8) {26,33,25,65,16,34,6,7,35}
|
||||||
|
[.#...#..] (0,3,7) (1,2,6) (0,1,4,5,6,7) (2,5,6) (0,7) (0,2,5) (1,3,4,5,7) {34,52,23,18,33,37,41,45}
|
||||||
|
[##..#..#..] (0,1,2,4,5,7,8,9) (3,4,6,9) (0,1,3,5,6,7,8) (0,2,3,4,6,7,8) (1,2,4) (1,3,4,5,6,7,8) (0,1,2,4,5,6) (0,1,5,8,9) (1,3,4,5,6,7,8,9) (0,4,7,9) (0,1,6,7,9) {71,59,35,53,80,48,57,75,63,62}
|
||||||
|
[###.#....#] (0,2,7,9) (0,5,6,8) (1,2,4,5,7,8,9) (3,7) (0,7,9) (4,6,8) (2,4,8) (3,5,7) (0,1,2,3,4,5,7) (0,1,3,4,5,8) (1,3,5,6,8,9) (2,8) {59,45,56,52,66,51,25,62,73,34}
|
||||||
|
[.###] (2,3) (0,3) (1,2,3) {107,18,36,143}
|
||||||
|
[....##] (3,4) (0,5) (0,1,3,5) (2,4) (3,4,5) (4,5) {143,8,16,32,59,173}
|
||||||
|
[.##.....] (1,4,5,6,7) (0,4,5,6,7) (1,2,4) (2,5,6) (1,2) (0,1,2,3,6,7) (1,2,3,6,7) (1,3,4,5,6,7) {23,167,69,33,139,144,165,148}
|
||||||
|
[...#..#.#.] (1,3,4) (3,6) (0,1,2,3,4,6,7,8,9) (0,1,3,5,6,7,8,9) (1,2,3,4,7) (2) (0,1,4,6,8,9) (0,1,2,3,4,9) (0,1,3,4,5,7,8,9) (0,3,8,9) (0,1,2,3,6,8,9) (1,2,3,4,6,7,8,9) {89,246,209,234,219,28,69,193,88,107}
|
||||||
|
[##...#] (1,2,4,5) (1,2,3,4) (0,2,4) (2,4) {15,20,204,17,204,3}
|
||||||
|
[##...##...] (0,5,9) (0,1) (6) (4,8) (0,1,5,8) (2,3,5,7,8) (0,1,2,4,5,7,9) (0,2,3,4,7,9) (2,3,4,5,6,7,8,9) (0,2,4,7) (0,1,3,4,5,6) (0,3,4,6,8,9) {74,35,52,41,64,60,22,52,38,60}
|
||||||
|
[.#.###] (2,5) (2,3,4) (1,2,3,4) (0,3,5) (1) {9,9,28,34,25,12}
|
||||||
|
[.##.#.#] (1,2,3,4) (1,2,4,5) (1,2,6) (0,1,4,6) (2,3,5) (1,2) (1,5,6) {12,48,50,29,36,26,20}
|
||||||
|
[..####..#] (0,1,2,4,5,7,8) (0,2,3,4,6,7) (0,1,2,3,4) (0,1,2,4,6,7,8) (0,2,3,5,6,8) (2,6,7,8) (1,4,8) (1,3,4,5,7,8) (0,6,8) (1,2,4,5,8) (0,7) {189,54,61,39,72,17,46,152,56}
|
||||||
|
[###.######] (1,2,4,5,7,8) (0,1,2,3,4,6,8,9) (0,1,2,3,4,5,6,9) (1,5,7,9) (2,3,4) (0,1,2,4,5,6,7,8,9) (3,5,6,7) (0,1,2,4,5,7,9) (0,1,3,4,5,8,9) {52,85,78,55,85,91,46,71,44,69}
|
||||||
|
[.###..###] (1,2,3,6,7) (2) (1,4,6) (1,2,5,6,8) (0,1,3,5,6,7,8) (1,3,5) (0,3,4,5,7) (0,5) {42,59,23,58,31,51,50,49,17}
|
||||||
|
[..#.] (0,1,2) (1,2,3) (0,3) (0) (1,2) (0,2,3) {30,27,34,20}
|
||||||
|
[##.#.#] (0,1,2,5) (0,1,4,5) (2,3) (1,3,4,5) {16,140,8,130,138,140}
|
||||||
|
[.##.####.#] (2,3,5,7) (0,1,2,6,8) (6) (1,2,4,5,7) (0,2,3,5,6,7,8,9) (1,2,4,5,6,7,9) (0,1,2,5,7,8) (0,3,4,5,6,9) (1,3) (0,1,4,5,7,8) {42,56,53,33,27,63,33,62,41,27}
|
||||||
|
[.#..#] (0,1,3,4) (1,2,3) (0,3) {23,29,14,37,15}
|
||||||
|
[#####.#.] (1,2,4,6) (0,1,4,5,6) (0,1,2,3,5,6) (0,1,2,6,7) (1,3,6,7) (0,2,4) (0,3,4,5,6) (6) (2,3,4,5,7) {48,56,30,46,58,43,91,24}
|
||||||
|
[.#....#] (0,1,5) (1,3,4,5,6) (0,4,6) (1,2,3,4,5) (0,1,2,3,4,6) {32,210,20,208,220,192,218}
|
||||||
|
[#.#...##] (0,1,2,3,5,6) (0,2,3,4,5,7) (0,2,4) (0,4,6,7) (1,2,7) (1,4,5) (0,2,6,7) {57,40,52,26,42,37,43,47}
|
||||||
|
[.#....###] (3,6,7,8) (1,2,3,4,5,6) (0,5,7) (2,4,5,6) (1,2,3,6) (2,3,4,5,6,7,8) (1,2,4,5,6,8) {17,38,59,40,40,57,60,26,16}
|
||||||
|
[#####] (0,1,2,4) (1,3) (2,3) (1,4) (2,3,4) (0,4) {27,33,24,25,32}
|
||||||
|
[.###] (0,2,3) (1,2,3) {3,3,6,6}
|
||||||
|
[##...#] (0,1,2,4,5) (0,5) (1,4) (0,2,3,5) (5) (0,1,4) (0,1,2) (2,3) {42,40,40,5,25,27}
|
||||||
|
[.###] (1,2,3) (0,1,2,3) {15,19,19,19}
|
||||||
|
[####.#.] (1,4,5,6) (0,1,2,3,5) (0,1,2,3,5,6) (2) (2,3) {35,44,68,51,9,44,26}
|
||||||
|
[#.####.#.] (1,4,5,6,8) (1,2,6,7) (0,2,3,6,7) (0,3,5,6,7,8) (1,4,7,8) (0,1,2,3,4,5,6,8) (1,4,8) {187,46,195,187,36,27,205,183,38}
|
||||||
|
[.#.##] (0,2,3,4) (2,3) (1,3,4) (0,1,3) {169,2,183,185,169}
|
||||||
|
[#.#.###] (0,2,5) (0,5,6) (1,2,3,4,5) (5) (1,4,6) (0,1,3,5,6) {29,31,12,19,19,56,36}
|
||||||
|
[####..#.##] (2,3,4,5,7,8) (0,1,2,3,5,6,7,8,9) (0,1,2,6) (0,4,5,6,9) (0,1,4,6,7,9) (2,7) (0,2,3,4,5,6,8) (0,1,4,6,8,9) {48,44,45,19,44,20,48,34,31,25}
|
||||||
|
[.#####.] (1,2,3,5,6) (3,6) (0,1,3,5,6) (1,5) (0,1) (0,2,5) (0,3,4) {43,37,29,55,9,52,46}
|
||||||
|
[#...#] (2,4) (0,1,2,3) (1,3,4) (0,4) {16,9,21,9,37}
|
||||||
|
[#.###.] (0,5) (0,3,4,5) (0,2) (0,1,2,3,4) (1,2) {65,34,53,36,36,27}
|
||||||
|
[.#..#.] (1,3,5) (1,2,3,4) (0,2,3,4,5) (0,1,3,4) (0,1,3) (3,4,5) (0,1,2,5) {45,50,21,45,32,15}
|
||||||
|
[..###] (2,3,4) (1,2,4) (0,3,4) (3,4) (0,1,3) {12,25,17,19,22}
|
||||||
|
[.###..##] (0,2,5,6) (1,4,5,6) (1,2,3,5,6) (0,4,5,6,7) (1,3,4,6) (1,3,7) (0,4,7) {38,34,22,21,42,37,45,29}
|
||||||
|
[####] (1,3) (0,1,2,3) {187,203,187,203}
|
||||||
|
[..#..##.] (0,1,2,4,5,6,7) (0,1,2,3,4,5) (4,6) (0,1,6,7) (1,3,5,7) (0,2,3,4,5,7) {37,38,30,38,42,48,29,52}
|
||||||
|
[..##] (0,3) (0,2) (1,3) {9,180,8,181}
|
||||||
|
[#.###.] (1,4,5) (2,3,4,5) (0,1,2,4) (0,1,2,5) (3,5) (1,3,4) (0,1,3) {46,59,45,48,40,44}
|
||||||
|
[#.#...] (0,1,3,4) (0,2) (0,2,3,4) (3,4,5) (1,2,4,5) (1,2,3) (2) {34,28,48,235,217,190}
|
||||||
|
[#...###.#] (1,2,4,5,6) (1,2,3,4,5,7,8) (2,3) (0,2,4,6) (0,5,7,8) (0,2,3,6,8) (1,2,4,5) {39,43,81,54,43,62,39,35,55}
|
||||||
|
[.###.#.##] (0,1,4,6,7,8) (0,4,6,7,8) (0,1,6,7) (0,3,4,5,8) (1,2,4,6,7,8) (0,1,3,4,5,6,7,8) (0,3,4,5) (1,2,3,5,7,8) (1,3,4,7) (4,7) (1,3,7,8) {40,34,17,42,57,32,27,51,54}
|
||||||
|
[#.#...##] (2,3,4,6) (1,2,4,5,6,7) (3,5,7) (0,6) (0,1,2,4,6) (1,3,4,6) (4,5,7) (1,4,5,6) (0,1,4,5,6,7) (0,1,2,3,6,7) {62,70,56,37,84,48,103,48}
|
||||||
|
[##..] (0,3) (1,2,3) (1,2) (0,2,3) (2) {20,12,48,32}
|
||||||
|
[.#.###] (1,2,4,5) (0,1,3) (0,2,3,4,5) (0,5) (0,3) (1,2,5) (0,1,5) (2,4) {50,45,29,27,18,48}
|
||||||
|
[.####] (1,3,4) (0,1,2,4) (0,2,3,4) (2,4) (0,1,2) {49,48,53,35,57}
|
||||||
|
[####..###] (0,1,3,4,7,8) (0,4,6,8) (1,7,8) (0,2,3,6) (0,1,3,4,8) (4,5) (2,7) (1,3,4,7,8) (1,5,6,8) (1,2) {39,76,24,56,72,25,13,51,66}
|
||||||
|
[##.#.#..] (2,3) (2,3,4) (0,3,5) (0,1,2,5) (0,4,6) (1,2,5,7) {55,30,39,25,20,46,20,11}
|
||||||
|
[#..#.#.#.] (0,3,5,6) (1,3,4,6,7,8) (1,2,6,8) (4,5) (0,1,3,4,8) (2,3,5,6,7,8) (0,2,5,6) (0,2,3,4,5,6,7) (0,3,4,5,7) (0,1,2,3,5,7,8) {258,55,58,283,84,265,273,70,68}
|
||||||
|
[#....##] (0,4) (0,1,3,5,6) (1,2,3) (0,1,2,3,6) (4,5,6) (0,1,3,4,5) (0,2,3,6) {43,37,21,45,47,42,32}
|
||||||
|
[..#...] (1,3,4,5) (0,1,2,3,5) (1,2,3,4) (0,4) {36,29,25,29,29,22}
|
||||||
|
[...##..] (0,1,4,5,6) (0,1,3,4,5,6) (0,1,2,3,5) (0,3,4,5) (3,5) (0,1,2,3) (1,3,4,6) {160,58,21,183,155,163,37}
|
||||||
|
[##..##..] (2,3,6) (0,1,4,7) (2,4,6,7) (2,4,6) (0,3,6) (1,4,6,7) (0,1,3,4,6,7) (3,4,5,6) (0,3,4,6) {21,24,33,36,48,5,62,38}
|
||||||
|
[#.....##] (1,2) (1,4,7) (2,3,4) (0,2,4,5) (1,3) (0,6,7) {7,27,35,19,28,5,2,10}
|
||||||
|
[##.....#.] (0,2,3,6,8) (1,3,4,5,7) (0,4,5,6) (1,2,3,4,6,7,8) (0,1,4,5,6,7,8) (1,2,5,8) (0,2,3,4,7) {33,65,38,41,62,57,41,56,50}
|
||||||
|
[#...###..] (2,3,4,5,7) (0,1,2,4,7,8) (0,1,2,3,5,6,7) (6,7,8) (4,5,8) (1,3,4,8) (5,8) (0,2) (0,2,3,5,6,7,8) {37,36,48,59,44,79,50,63,80}
|
||||||
|
[.##..] (1,3) (3) (0,1,2) (0,4) (0,1,3,4) (1,2) {9,28,12,22,5}
|
||||||
|
[###..#.#.#] (1,2,4,6,7,8) (4,6) (0,2,5,6,7,9) (0,1,2,3,5,6,8,9) (0,1,6,8) (0,2) (1,2,6,7) (0,3,5) (1,2,6,7,9) (3,7,9) (0,1,6,7,8) (1,2,3,4,7,8,9) (0,2,3,4,5,7,9) {182,75,172,36,36,140,203,188,59,167}
|
||||||
|
[....#..] (0,1,3) (0,4,6) (1,2) (0,2,4) (3,5,6) (1,4,5,6) (0,3) (0,1,3,4) {73,25,18,47,42,12,29}
|
||||||
|
[....#....#] (0,1,2,5,6,7,8) (0,1,2,3,4,6,7,8,9) (0,2) (0,1,4,5,6,8,9) (2,3,8,9) (4,9) (1,2,3,5,7,8,9) (2,6,7,8) (5,7,8) (0,1,2,3,4,6,7,9) (1,3,5,7,8,9) {37,49,63,30,20,49,52,67,75,41}
|
||||||
|
[..#.##..] (0,2,5,6) (0,4,7) (0,1,2,3,5,7) (6,7) (1,2,4,5) (0,1,2,4,5,7) (0,1,2,4,7) {197,178,198,155,23,185,40,197}
|
||||||
|
[###.#] (3,4) (0,2,3,4) (0,2,3) (1,3,4) (1,2,3) (0,1,2) {39,44,54,47,17}
|
||||||
|
[....#.#.] (3,6) (1,2,3,4) (2,3,6,7) (2,5,6,7) (0,1,2,3,5,7) (2,3,4) (2,3,5) (0,3,4,5,6,7) (3,4) (1,2,3,6) {17,13,48,86,56,34,44,26}
|
||||||
|
[..#.] (0,3) (1,2) (2,3) (1,2,3) {13,17,20,32}
|
||||||
|
[..#..] (0,1,2,4) (0,2,3) (2) {4,0,16,4,0}
|
||||||
|
[...##.] (3,4) (0,2,5) (1,3) (0,1,4) (0,3,5) (1,4) (1,2) {26,47,16,31,29,17}
|
||||||
|
[#.#.#..##] (2,3) (0,2,5,7,8) (0,6) (2,3,4,5,6,8) (1,3,4,5,6,8) (2,4,6,7) (1,8) (0,2) {42,22,58,39,39,43,54,28,45}
|
||||||
|
[##.#] (0,1,3) (0,2,3) {10,9,1,10}
|
||||||
|
[##....] (2,3) (2,3,4,5) (0,5) (1,2,3) (2,3,4) (0,2,3,5) {22,16,56,56,12,33}
|
||||||
|
[.#...#..] (0,2,3,6,7) (0,1,2,3,5,7) (6,7) (0,1,2,3,6,7) (0,1,2,3,5,6) (0,3,4,7) (4,5) (1,4,5,7) (0,1,2,3,5,6,7) {50,36,49,50,14,35,49,57}
|
||||||
|
[#.#..#] (2,4) (0,2,5) (2,3,4,5) (1,2,4) (0,2,3,4,5) (1,3,4,5) (2,3) {18,26,65,61,72,56}
|
||||||
|
[..##] (1,2) (0,2) (0,3) {22,1,11,12}
|
||||||
|
[.###.###..] (0,1,2,3,6,8,9) (0,5,9) (1,2,3,4,5,6,8,9) (0,1,2,4,5,7,8,9) (0,1,2,3,7,8,9) (2,4,7) (1,2,5,6,8) (3,4,5,8,9) (4,7,8,9) {218,225,238,230,43,42,202,36,239,243}
|
||||||
|
[.#...#.#.] (4,8) (0,2,3,7,8) (0,1,2,8) (0,2,3,4,5,6,8) (1,2,6) (2,6,7,8) (3,6,8) (0,2,3,4,5,7,8) {25,23,51,35,26,9,47,27,75}
|
||||||
|
[..#...###.] (0,1,4,5,6,9) (3,4,6,9) (1,2,3,6,8) (0,2,3,4,5,7,8,9) (1,3,8) (0,2,5,7,8,9) (1,2,3,5) (0,3,4,6,8) (3,5) (3,5,6) (2,7) (9) {37,30,35,65,44,39,60,26,38,40}
|
||||||
|
[..##...##.] (0,1,4,8,9) (2,3,7) (2,3,4,5,7) (4,6,7,8) (5,6) (1,5,9) (0,2,3,4,5,6,8,9) (2,5,6,9) (0,6) (1,8) (1,5,8,9) (2,9) (1,3,4,7) {17,38,39,24,32,49,18,24,35,55}
|
||||||
|
[###.#] (0,2) (4) (0,2,3) (3,4) (0,1,2,4) (0,1,2) {45,28,45,18,38}
|
||||||
|
[.###] (0,2) (1,2,3) {19,195,214,195}
|
||||||
|
[##.#] (3) (1,2) (2) (0,2,3) (0) {114,14,120,114}
|
||||||
|
[.##...] (1,2,5) (1,3,4) (0,2,4,5) (2) (0,3,5) {11,31,39,21,20,27}
|
||||||
|
[.##......] (0,2,4,5,6) (2,3,4,6,8) (0,1,2,3,5,6,7) (0,5,6,7,8) (2,3,4,5,8) (1,4,7) (8) (0,1,3,4,6,7,8) (3) (0,1,2,7) {46,32,56,51,44,47,34,43,52}
|
||||||
|
[.###] (0,2) (0,3) (1) (2,3) {12,3,15,15}
|
||||||
|
[#.#..##..#] (1,5,7) (0,1,2,3,4,6,7,8,9) (2,9) (0,5,6) (1,4,9) (1,2,5,7,9) (0,2,8,9) (4,9) {23,28,40,3,28,29,18,17,8,65}
|
||||||
|
[#..#.###.] (1,2,3) (0,2,3,4,7) (1,3,4,5,6,7,8) (0,2,4,5,6,8) (1,2,3,5,8) (0,2,4,5,6,7,8) (0,2,5,8) (0,1,2,3,4,5,7) (2,3,8) (1,3,6,7) {196,226,235,250,204,219,51,222,70}
|
||||||
|
[...#.] (2,3) (0,2,4) (0,2,3) (1,4) (1,2,4) {37,26,61,26,43}
|
||||||
|
[..#.#.##.#] (0,3,4,5,6,7,8,9) (0,1,2,5,6,7,8) (0,2,3,4,5,6,7,8,9) (1,2,4,7) (0,8) (5,6) (0,1,2,3,5,6,7,8) (0,1,2,3,4,5,6,7) (0,2,3,4,5,6,8,9) (1,3,6,8) (0,2,3,6,7,9) (1,2) (0,4,5,7,9) {91,200,210,76,78,74,83,76,72,48}
|
||||||
|
[..#.] (0) (0,2) (1,2,3) (2) (1) (2,3) {32,11,50,15}
|
||||||
|
[#.##.###..] (0,4,5,6,7,8,9) (2,3,4,5,6,7,9) (4,6,8) (0,1,3,4,6,7,8,9) (0,1,2,3,4,7) (1,2,4,8) (1,4) (0,1,2,3,4,5,6,8,9) (1,2,4,7,8) (0,2,3,5,8) (1,4,5,6,7) (1,4,9) {73,109,75,65,139,66,78,83,82,68}
|
||||||
|
[.####.#...] (0,3,4,6,7,8) (2,9) (0,1,2,3,4,5,6,8) (1,2,3,4,5,6,8,9) (0,1,2,3,7) (0,2,3,5,8) (0,1,2,3,4,5,6,7,9) (0,1,3,4,6) (0,1,4,6,9) (0,3,4,5,6,7,8,9) {60,44,35,48,45,24,45,33,27,29}
|
||||||
|
[.###..#] (0,1,2,3,6) (1,4) (3,6) (0,1,4,5) (1,2,4,5,6) (0,1,6) (1,2,5) (0,1,3,5) {47,80,22,28,41,41,43}
|
||||||
|
[.##..] (2,3) (0,1,2,3) (0,3,4) (0,1,2) (2,3,4) (3,4) (4) {50,37,65,71,59}
|
||||||
|
[.#..###.] (1,3,4) (0,1,4,5,6) (4,5) (0,1,7) (6) (1,2,3,4) (2,3,5,6) (0,3,4,5,6) {31,28,158,177,46,184,174,10}
|
||||||
|
[#..#.#....] (0,3,4) (1,4,5,6,7,8) (1,3,4,5,7,8) (0,5,7,8) (0,1,2,3,5,8,9) (0,3,4,5,6,7,8) (0,2,4,8,9) (0,6) (2,3,5,6,7,8,9) (0,2,3,4,5,7,9) (1,2,4,5,6,7,8,9) {84,45,59,70,73,75,52,57,78,59}
|
||||||
|
[#.#..] (1,3,4) (2,4) (0,2) (0,1,4) (2,3) (1,3) (0,4) {17,29,14,28,25}
|
||||||
|
[#.#.#.##] (1,4,7) (0,2,5,6) (4,7) (2,3,4,6,7) (1,3,5,6) (0,2,4,6,7) {19,200,38,24,237,17,43,237}
|
||||||
|
[..##.##...] (0,1,3,5,6,7,8,9) (0,2,4,5,6,8) (1,3,6,9) (0,1,2,3,4,5,7,8,9) (3,4,5) (2,3,4,5,9) (1,2,4,5,8) (0,2,3,7,9) (1,2,6,7,8,9) (1,2,5,9) (1,3) (1,7) {56,86,93,96,79,106,45,49,60,87}
|
||||||
|
[.#.###] (0,5) (0,4,5) (2,3,4,5) (0,1) (0,2) {247,198,18,4,22,39}
|
||||||
|
[##.#.] (0,2,3,4) (0,2) (0,1,2,3) (0,1,4) {53,29,33,14,25}
|
||||||
|
[#####] (1,3,4) (0,2,3,4) (0,2) {36,15,36,31,31}
|
||||||
|
[..###] (0,2,4) (1,2,4) (0,3) {13,5,9,9,9}
|
||||||
|
[.#..] (0,2) (1,2,3) (0,3) (1,2) (0,1,3) {29,14,18,21}
|
||||||
3
src/exercises/assets/day_10_test_input.txt
Normal file
3
src/exercises/assets/day_10_test_input.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[.##.] (3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}
|
||||||
|
[...#.] (0,2,3,4) (2,3) (0,4) (0,1,2) (1,2,3,4) {7,5,12,7,2}
|
||||||
|
[.###.#] (0,1,2,3,4) (0,3,4) (0,1,2,4,5) (1,2) {10,11,11,5,10,5}
|
||||||
543
src/exercises/assets/day_11_input.txt
Normal file
543
src/exercises/assets/day_11_input.txt
Normal file
@@ -0,0 +1,543 @@
|
|||||||
|
pnn: opd
|
||||||
|
gyc: elv lvv
|
||||||
|
mnx: ivr ibb
|
||||||
|
vgu: kzj pqv
|
||||||
|
ilm: eej qlx wgv qrg
|
||||||
|
zgs: zuw xsc qna ere thp jmf wxk myq oip tey eva ydb izr yhm
|
||||||
|
ifm: qlj
|
||||||
|
cuj: out
|
||||||
|
ocn: bvx hpb jee iad jqj bzm hig abe kng ggh oqo pzp iao hud jpk
|
||||||
|
nme: hli
|
||||||
|
wfq: ewj
|
||||||
|
thc: wzt pol iee ogz
|
||||||
|
sig: qlx wgv
|
||||||
|
dgw: kgf xlt
|
||||||
|
hly: wmu xku
|
||||||
|
rbs: odx
|
||||||
|
zvp: opd zkx xeu bhx zgs
|
||||||
|
cki: ztj you
|
||||||
|
itw: nya qyb eae
|
||||||
|
onp: exe gsv
|
||||||
|
zle: out
|
||||||
|
qhv: pmn tut uhu
|
||||||
|
ibt: ncx
|
||||||
|
pum: ztj you
|
||||||
|
tmh: hbx hsh ktr nph dcg
|
||||||
|
vyy: krx
|
||||||
|
ktr: grm
|
||||||
|
ggh: ilm ang bwj
|
||||||
|
wtb: rbs aaz
|
||||||
|
ugk: fet
|
||||||
|
ltn: odx ztj
|
||||||
|
oah: out
|
||||||
|
xcx: pqv wfq elj
|
||||||
|
apt: out
|
||||||
|
dac: muz fio pum qyf
|
||||||
|
lwa: qfc eqq qoq orb
|
||||||
|
hiv: xjx enn sie
|
||||||
|
xvu: vze aek tjd wll
|
||||||
|
bhx: qna mon voe vxt myq ere jmf wxk ljp yhm zuw tey nha nme thp ydb mfv ozp izr
|
||||||
|
lmb: ltn wgp mpp
|
||||||
|
ksl: xku wmu grm
|
||||||
|
hns: zle nvu
|
||||||
|
vmw: bxw
|
||||||
|
yfn: qju
|
||||||
|
vpl: pok
|
||||||
|
kzj: kkj ewj
|
||||||
|
mon: ure xhk ahv mty
|
||||||
|
xll: vol bdk
|
||||||
|
wmo: dca gnt
|
||||||
|
miv: hly qhb eru mnw
|
||||||
|
ica: msp exg thc
|
||||||
|
prk: ssx dca dtc
|
||||||
|
hud: psu
|
||||||
|
oqo: tyx odi ljw
|
||||||
|
nqe: hns
|
||||||
|
hlr: lmm ymk xcx
|
||||||
|
mwt: cuj apt mtq bqu
|
||||||
|
ere: fod dxi
|
||||||
|
wex: uhy wvp
|
||||||
|
ogp: lhh weu
|
||||||
|
qab: out
|
||||||
|
exg: pol
|
||||||
|
hvq: out
|
||||||
|
dlf: skp dmm nci vmw
|
||||||
|
oey: out
|
||||||
|
mge: edd dmm skp nci
|
||||||
|
yhm: mty dnc xhk
|
||||||
|
pol: xgp ljd ufv ibt pcj qpe jvv yey uhx
|
||||||
|
msp: ogz wzt
|
||||||
|
kwv: zlt jlx
|
||||||
|
wgp: you
|
||||||
|
bzm: bww oby oii
|
||||||
|
mqw: elv jhz lvv
|
||||||
|
xyv: opd zkx bhx zgs
|
||||||
|
vyl: pbz wmy bdk
|
||||||
|
nya: hcb fet fsf
|
||||||
|
tut: bxw xku sbb wmu grm
|
||||||
|
uyz: fay jvm
|
||||||
|
zxo: opd zkx bhx xeu
|
||||||
|
rfp: ckl nzc msp
|
||||||
|
jbf: vlu pss ipe
|
||||||
|
thv: xeu
|
||||||
|
plf: ibb sgk ivr ibw
|
||||||
|
pmq: lex cyo
|
||||||
|
opb: qlj
|
||||||
|
tlr: fay uey
|
||||||
|
uhx: vyy uqc erw
|
||||||
|
efr: hiv zhy
|
||||||
|
mkm: bha
|
||||||
|
sxu: cyo exe gsv lex
|
||||||
|
lex: rfp
|
||||||
|
eae: hcb isb fet
|
||||||
|
xkk: yia mwt mgs
|
||||||
|
ywb: qfc qoq orb eqq wjp
|
||||||
|
thp: fod dxi
|
||||||
|
vcz: djo yqr
|
||||||
|
voe: hli ovs yyd
|
||||||
|
baa: azd
|
||||||
|
oip: ovs
|
||||||
|
iao: mqw gyc
|
||||||
|
ehf: rdv akw
|
||||||
|
vcu: ena
|
||||||
|
cvo: zle oah nvu
|
||||||
|
gft: mpp
|
||||||
|
rrc: oah der
|
||||||
|
tgp: out
|
||||||
|
pzd: zgi
|
||||||
|
myq: ovs lgq hli
|
||||||
|
der: out
|
||||||
|
xjx: iha tog
|
||||||
|
bmq: mjz drr
|
||||||
|
dtc: oey rqm
|
||||||
|
pyp: zgi unr
|
||||||
|
zgi: ztj
|
||||||
|
emu: ill xfs qpb
|
||||||
|
pfs: gsv exe cyo
|
||||||
|
koy: msp ckl
|
||||||
|
xml: umi nfp dpz bqi aot
|
||||||
|
vfz: qst
|
||||||
|
zpe: ifm brt opb
|
||||||
|
dpz: fsf isb fet
|
||||||
|
zhy: enn xjx
|
||||||
|
wvp: lnf umb
|
||||||
|
xnb: nfp aot bqi
|
||||||
|
uvf: ibb fwe sgk
|
||||||
|
fwe: fen yxo
|
||||||
|
ljd: pgg gke okt
|
||||||
|
lgq: ugk
|
||||||
|
qpe: vyy bgp erw
|
||||||
|
hgk: mwt
|
||||||
|
bzq: pgs esy
|
||||||
|
mdz: pum cge qyf muz fio
|
||||||
|
vlm: opd bhx zgs
|
||||||
|
odx: xfh oyz ehh iuo ord vpl drs eyt xkx baa mfl
|
||||||
|
ufv: rho
|
||||||
|
fen: yug kmf woh
|
||||||
|
zbl: hud szr iao oqo pzp hig abe ggh kng bzm jqj iad jee hpb mcr ipg bvx
|
||||||
|
yet: jhz
|
||||||
|
lnf: xkk hgk aqi
|
||||||
|
wmy: aak qdq
|
||||||
|
you: drs plk eph csl wex vld ord vfz idu
|
||||||
|
khw: skt ssx dca dtc
|
||||||
|
ggt: nqp
|
||||||
|
nha: zhy ite
|
||||||
|
bpf: zle der nvu oah
|
||||||
|
qmu: yva wtb
|
||||||
|
pti: ilx xve vjw
|
||||||
|
qun: vyy bgp
|
||||||
|
tha: aot bqi dpz umi nfp
|
||||||
|
txq: xmv zae bcr
|
||||||
|
los: hvq nsb
|
||||||
|
ucq: yug
|
||||||
|
aot: fsf
|
||||||
|
ibb: fen ucq
|
||||||
|
eva: gnx ijp
|
||||||
|
wgf: fet
|
||||||
|
uxu: fkw qnc lbd
|
||||||
|
qgw: zgs bhx zkx opd
|
||||||
|
hdl: jnj hrx
|
||||||
|
vze: wzt ogz iee
|
||||||
|
wjp: iee pol qju wzt
|
||||||
|
kuz: pzd pyp rho zqe
|
||||||
|
vxt: hiv ite
|
||||||
|
nld: cgq miv
|
||||||
|
gke: dve twf
|
||||||
|
nfp: isb fsf hcb
|
||||||
|
brt: xvu
|
||||||
|
ssx: oey njy
|
||||||
|
ite: enn sie
|
||||||
|
gsv: rfp koy ica
|
||||||
|
xbi: bhx zkx opd
|
||||||
|
egs: grm wmu sbb xku
|
||||||
|
dcg: wmu bxw xku
|
||||||
|
qyb: fsf isb hcb
|
||||||
|
azd: swd hxc
|
||||||
|
eim: ptq wtb yva
|
||||||
|
jpk: aow oii oby bww
|
||||||
|
hig: yet
|
||||||
|
kkj: qab evn twt
|
||||||
|
raz: nxx lps nld
|
||||||
|
twt: out
|
||||||
|
uqc: omz ipk mne
|
||||||
|
vlk: gnx hdl mtr
|
||||||
|
jlx: dcg ktr hbx
|
||||||
|
rdj: jsa kxe nfm
|
||||||
|
mne: odx ztj you
|
||||||
|
ure: qth
|
||||||
|
evn: out
|
||||||
|
ofa: zgi
|
||||||
|
qlx: xyv xkg jcy thv
|
||||||
|
elj: ewj kkj pan
|
||||||
|
pbz: vcu aak
|
||||||
|
xfy: cgq miv vii
|
||||||
|
yva: cki aaz
|
||||||
|
skp: sbb wmu grm
|
||||||
|
zgr: jbn djo
|
||||||
|
ahv: fft
|
||||||
|
zmp: rfu pbz wmy vol bdk
|
||||||
|
lmm: elj kzj
|
||||||
|
ijp: hrx jnj
|
||||||
|
eej: xbi xkg xyv jcy thv
|
||||||
|
vyz: lwa yyr duu
|
||||||
|
ubk: xyg mge ufe
|
||||||
|
hbx: bxw sbb wmu grm
|
||||||
|
ltq: mwt yia
|
||||||
|
xve: vxd cfr gft
|
||||||
|
hrx: ehf
|
||||||
|
elw: weu iml zuu lhh
|
||||||
|
nph: wmu sbb grm xku bxw
|
||||||
|
okt: twf mdz dac
|
||||||
|
fpe: rho zqe
|
||||||
|
lbs: zgr vcz
|
||||||
|
qfc: pol iee wzt
|
||||||
|
kcc: xmv vrk zae bcr
|
||||||
|
dfi: qfc qoq
|
||||||
|
war: pmn
|
||||||
|
gnx: jnj uxp bmq hrx
|
||||||
|
vrm: equ tfg
|
||||||
|
grm: ggt myt pmq vyz zpe
|
||||||
|
csl: xll
|
||||||
|
qdq: qah los ena
|
||||||
|
tjy: out
|
||||||
|
yjs: wzt qju iee
|
||||||
|
tiv: lhh iml weu
|
||||||
|
vld: wgb uhy
|
||||||
|
wqv: jlx tmh yeh
|
||||||
|
rkw: wmu bxw xku
|
||||||
|
zae: lrp
|
||||||
|
ipe: ymk xdb
|
||||||
|
duo: wzt ogz qju
|
||||||
|
iml: opd
|
||||||
|
tce: xfy lps nxx
|
||||||
|
fod: xml xnb tha
|
||||||
|
qrg: jcy xbi
|
||||||
|
qhb: xku sbb wmu grm
|
||||||
|
dde: vol bdk rfu
|
||||||
|
qju: pcj pti qvy bjz qun rdj kju cnt huy rbj qpe
|
||||||
|
zuu: zkx xeu bhx zgs
|
||||||
|
ewj: evn twt tjy
|
||||||
|
ejf: brt
|
||||||
|
xkx: zap hhw azd
|
||||||
|
skt: njy
|
||||||
|
kmf: egs
|
||||||
|
lhh: zgs xeu bhx zkx
|
||||||
|
uqk: nfm qmu jsa eim
|
||||||
|
mcr: sig bwj
|
||||||
|
duu: qfc qoq wjp
|
||||||
|
uey: qhv prl
|
||||||
|
dve: pum cge qyf muz
|
||||||
|
yqr: prk kvk
|
||||||
|
qth: wgf ede pgs
|
||||||
|
mfv: rwg umy
|
||||||
|
abe: bww oby
|
||||||
|
drr: akw
|
||||||
|
mpp: ztj odx
|
||||||
|
iha: isb
|
||||||
|
kvk: skt gnt dtc
|
||||||
|
huy: nfm kxe qmu jsa eim
|
||||||
|
dmm: bxw xku sbb grm
|
||||||
|
mgs: apt cuj
|
||||||
|
ptq: aaz cki
|
||||||
|
uma: cki rbs
|
||||||
|
cyo: ica koy rfp
|
||||||
|
yjl: xll vyl
|
||||||
|
lrp: wzt qju iee pol ogz
|
||||||
|
uvv: ufe dlf
|
||||||
|
pss: xcx
|
||||||
|
ozp: ite
|
||||||
|
xfh: vlu qst
|
||||||
|
nzc: ogz iee pol
|
||||||
|
nbr: uhu pmn glj
|
||||||
|
qrf: zkx opd zgs bhx
|
||||||
|
mnw: bxw
|
||||||
|
uxp: mjz
|
||||||
|
jgp: tsx jaq ekw
|
||||||
|
bml: rrc bpf
|
||||||
|
idu: uhy
|
||||||
|
psu: fkw hqn lbd
|
||||||
|
bwj: kyw qlx wgv qrg
|
||||||
|
eqq: pol qju
|
||||||
|
pmn: grm sbb
|
||||||
|
myt: ywb lwa duu
|
||||||
|
pqv: kkj
|
||||||
|
zkx: efr ydb mfv all izr zuw vlk tey nme thp yhm qna xsc voe vxt oip myq wxk jmf
|
||||||
|
tfg: kgf xlt duo
|
||||||
|
ovg: isb fsf hcb
|
||||||
|
iad: uxu rru
|
||||||
|
cfr: mpp
|
||||||
|
hqn: nbo pnn zxo
|
||||||
|
bjz: vjw xve ncx ilx
|
||||||
|
ckl: qju iee ogz
|
||||||
|
edd: wmu
|
||||||
|
yeh: hbx dcg nph ktr
|
||||||
|
djo: kvk khw rby wmo
|
||||||
|
sbu: fsf isb fet hcb
|
||||||
|
lvv: vlm dzr
|
||||||
|
ftk: ifm brt bha
|
||||||
|
fft: pgs ede esy ojl
|
||||||
|
kgf: iee ogz wzt
|
||||||
|
hpb: psu rru uxu
|
||||||
|
jvv: okt pgg
|
||||||
|
erw: omz
|
||||||
|
lbd: snl
|
||||||
|
jyh: exg nzc
|
||||||
|
snl: zgs xeu zkx
|
||||||
|
uuy: nld nxx
|
||||||
|
qpb: zgs bhx zkx
|
||||||
|
prl: tut
|
||||||
|
nbo: zgs xeu opd
|
||||||
|
nfm: wtb ptq yva uma
|
||||||
|
vjw: gft vxd
|
||||||
|
qna: ced dxi
|
||||||
|
uwx: der nvu
|
||||||
|
oyz: uhy wgb
|
||||||
|
wzt: huy jvv qpe fpe qun uqk pcj kju cnt ufv ljd rdj qvy
|
||||||
|
pan: evn qab
|
||||||
|
swd: ieu nqe
|
||||||
|
dzr: opd zkx bhx zgs
|
||||||
|
kxe: ptq yva
|
||||||
|
jmf: rwg sys
|
||||||
|
qpc: vrm hyu nqp
|
||||||
|
xyg: dmm edd vmw nci
|
||||||
|
eph: hlr ipe vlu pss
|
||||||
|
exe: koy rfp jyh ica
|
||||||
|
ced: tha
|
||||||
|
ehh: vcz zgr
|
||||||
|
blb: vrm
|
||||||
|
szr: bwj sig
|
||||||
|
drg: umi nfp dpz
|
||||||
|
weu: bhx xeu zgs zkx
|
||||||
|
sfk: qhv nbr
|
||||||
|
ffk: isb fsf hcb
|
||||||
|
aaz: you odx
|
||||||
|
nxx: cgq
|
||||||
|
iee: pcj qvy qun ufv bjz fpe
|
||||||
|
vlu: ymk vgu xcx xdb
|
||||||
|
bvx: tyx odi
|
||||||
|
oii: lov xqv
|
||||||
|
nci: sbb bxw
|
||||||
|
kju: rho pyp ofa pzd
|
||||||
|
pzp: yet mqw gyc
|
||||||
|
wdd: bcr
|
||||||
|
jhz: dzr vlm
|
||||||
|
xlt: pol iee ogz
|
||||||
|
bdk: qdq aak vcu
|
||||||
|
oqz: nxx
|
||||||
|
fzw: lhh zuu weu zvp
|
||||||
|
krx: odx
|
||||||
|
ieu: cvo uwx rrc bpf
|
||||||
|
umi: fet fsf hcb
|
||||||
|
mfl: zmp
|
||||||
|
bww: emu
|
||||||
|
rby: dca gnt
|
||||||
|
qvy: nfm eim
|
||||||
|
rfu: qdq aak
|
||||||
|
muz: ztj you odx
|
||||||
|
cnt: okt
|
||||||
|
fgd: nqp hyu
|
||||||
|
jqj: ang bwj
|
||||||
|
wmu: ogj bon pfs txq wdd vyz kcc zpe fgd ggt mkm ftk ran sxu myt onp vrb ejf qpc pmq
|
||||||
|
stt: xyg
|
||||||
|
xkg: zgs bhx zkx opd
|
||||||
|
odm: nxx lps nld
|
||||||
|
bgp: ipk mne
|
||||||
|
qst: xcx ymk vgu xdb lmm
|
||||||
|
lov: qgw
|
||||||
|
oyo: wqv iva
|
||||||
|
uvr: ltn
|
||||||
|
ilx: gft lmb uvr vxd
|
||||||
|
unr: you ztj odx
|
||||||
|
ojl: isb hcb
|
||||||
|
vol: qdq
|
||||||
|
jcy: opd zkx xeu bhx zgs
|
||||||
|
sgk: yxo ucq
|
||||||
|
ztj: vld vfz baa eyt xkx eph mfl plk iuo idu ehh vpl xfh oyz csl jbf lbs drs yjl wex
|
||||||
|
ncx: uvr lmb gft cfr
|
||||||
|
ipg: uxu
|
||||||
|
qyf: ztj odx
|
||||||
|
ipk: ztj
|
||||||
|
mty: bzq qth
|
||||||
|
mjz: fvj rdv
|
||||||
|
sie: sbu iha tog
|
||||||
|
eyt: azd zap
|
||||||
|
orb: wzt ogz pol iee
|
||||||
|
esy: isb
|
||||||
|
iva: yeh tmh
|
||||||
|
slh: uhu glj
|
||||||
|
xqv: qrf xfs
|
||||||
|
mll: yqr djo jbn
|
||||||
|
ydb: xhk ure ahv dnc mty
|
||||||
|
gnt: rqm
|
||||||
|
all: ure mty dnc
|
||||||
|
odi: byx hrv tsx jaq ekw
|
||||||
|
xeu: ljp vxt myq ere jmf xsc qna izr ydb mfv eva tey vlk nme thp zuw
|
||||||
|
tjd: ogz qju wzt
|
||||||
|
cge: odx ztj you
|
||||||
|
ope: mgs
|
||||||
|
xku: pfs txq bon mkm ftk ggt pmq sxu qpc vyz fgd
|
||||||
|
ljp: umy rwg
|
||||||
|
mtq: out
|
||||||
|
rru: fkw qnc lbd
|
||||||
|
chu: uwx bpf hns
|
||||||
|
vti: eae
|
||||||
|
xmv: yjs
|
||||||
|
jsy: zvp lhh
|
||||||
|
ogj: dfi
|
||||||
|
bon: vrm
|
||||||
|
ovs: ffk ugk
|
||||||
|
hcb: uyz tlr uvv ubk uvf iez mnx raz pzs tce stt uuy oqz anf rkh xud oyo plf trv
|
||||||
|
dnc: bzq qth
|
||||||
|
hxc: chu glu nqe
|
||||||
|
tsx: elw ogp
|
||||||
|
akw: hcb
|
||||||
|
fay: prl slh
|
||||||
|
gcl: bxw wmu sbb
|
||||||
|
vrb: lwa ywb yyr
|
||||||
|
jvm: qhv war
|
||||||
|
vxd: wgp
|
||||||
|
nvu: out
|
||||||
|
lqw: abe szr hpb hud iad jqj
|
||||||
|
eru: sbb
|
||||||
|
rkh: kwv wqv
|
||||||
|
fdb: bml ieu chu
|
||||||
|
rwg: vti
|
||||||
|
zqe: rpv unr
|
||||||
|
ang: eej kyw
|
||||||
|
yxo: yug kmf
|
||||||
|
byx: fzw ogp elw tiv
|
||||||
|
xgp: gke okt
|
||||||
|
hhw: fdb swd
|
||||||
|
xsc: hiv zhy
|
||||||
|
xdb: elj pqv wfq
|
||||||
|
oby: xqv
|
||||||
|
xfs: zkx zgs bhx xeu
|
||||||
|
aow: lov emu
|
||||||
|
qnc: snl ecl
|
||||||
|
zlt: dcg nph ktr hbx hsh
|
||||||
|
opd: ljp qna xsc mon myq wxk voe oip mfv eva efr izr ozp nha tey
|
||||||
|
woh: rkw gcl
|
||||||
|
qlj: vze tjd
|
||||||
|
hli: ffk ovg
|
||||||
|
tey: hdl ijp gnx
|
||||||
|
iez: iva wqv
|
||||||
|
wgv: thv xyv
|
||||||
|
uhu: xku bxw wmu sbb
|
||||||
|
trv: uey
|
||||||
|
elv: ass
|
||||||
|
equ: duo xlt
|
||||||
|
efj: wll tjd aek vze
|
||||||
|
ufe: nci
|
||||||
|
enn: tog iha sbu
|
||||||
|
fet: plf tce hxn oyo xud uuy uvf uvv mnx odm tlr uyz
|
||||||
|
wgb: zoe
|
||||||
|
bxw: onp vrb ejf ogj qpc kcc
|
||||||
|
rdv: fsf fet isb
|
||||||
|
nqp: tfg equ
|
||||||
|
glu: bpf rrc uwx hns cvo
|
||||||
|
izr: ahv xhk dnc
|
||||||
|
twf: pum
|
||||||
|
ass: bhx xeu
|
||||||
|
hrv: tiv
|
||||||
|
yyd: ffk
|
||||||
|
umb: ltq ope xkk
|
||||||
|
mtr: bmq uxp
|
||||||
|
ecl: opd zkx
|
||||||
|
drs: zmp vyl dde
|
||||||
|
rho: zgi unr
|
||||||
|
cgq: ksl mnw hly
|
||||||
|
ena: hvq
|
||||||
|
fsf: hxn pzs oyo rkh xud uuy plf
|
||||||
|
aek: ogz qju iee
|
||||||
|
rqm: out
|
||||||
|
jsa: wtb yva uma
|
||||||
|
anf: xyg dlf
|
||||||
|
rbj: rho pyp pzd ofa
|
||||||
|
kng: ljw jgp odi tyx
|
||||||
|
pgs: fet
|
||||||
|
dja: eae qyb
|
||||||
|
lps: cgq
|
||||||
|
omz: you ztj
|
||||||
|
kyw: xyv xkg jcy
|
||||||
|
yyr: qfc qoq eqq
|
||||||
|
ede: fsf
|
||||||
|
xud: ibw ibb fwe
|
||||||
|
hyu: dgw
|
||||||
|
pok: swd hxc
|
||||||
|
umy: itw dja
|
||||||
|
yia: apt mtq cuj tgp
|
||||||
|
yug: gcl rkw
|
||||||
|
jbn: rby kvk khw prk
|
||||||
|
bqi: hcb
|
||||||
|
pcj: erw bgp vyy
|
||||||
|
aak: qah los ena
|
||||||
|
fio: odx
|
||||||
|
bcr: yfn yjs
|
||||||
|
ivr: fen yxo
|
||||||
|
qah: hvq zzs
|
||||||
|
iuo: wvp uhy
|
||||||
|
vii: hly qhb
|
||||||
|
qoq: iee pol wzt
|
||||||
|
xhk: qth fft
|
||||||
|
uhy: zoe lnf
|
||||||
|
pzs: sfk
|
||||||
|
pgg: twf mdz dac
|
||||||
|
ogz: huy jvv rbj bjz qun uqk ibt kuz kju uhx rdj ljd
|
||||||
|
hxn: ufe mge xyg
|
||||||
|
ibw: ucq
|
||||||
|
dca: oey njy rqm
|
||||||
|
isb: plf trv pzs hxn anf oyo rkh xud oqz stt uuy iez uvf ubk uvv raz mnx odm uyz
|
||||||
|
wll: wzt qju pol
|
||||||
|
glj: bxw wmu
|
||||||
|
jnj: ehf drr mjz
|
||||||
|
njy: out
|
||||||
|
tog: hcb fet fsf
|
||||||
|
sys: dja vti
|
||||||
|
rpv: ztj odx
|
||||||
|
nsb: out
|
||||||
|
zuw: mtr ijp gnx
|
||||||
|
ymk: wfq pqv elj
|
||||||
|
ill: zkx xeu bhx zgs
|
||||||
|
ord: zap azd pok
|
||||||
|
bha: efj xvu qlj
|
||||||
|
zoe: aqi hgk
|
||||||
|
bqu: out
|
||||||
|
wxk: ovs
|
||||||
|
svr: lqw ocn zbl
|
||||||
|
jee: yet
|
||||||
|
zzs: out
|
||||||
|
fvj: hcb fsf fet isb
|
||||||
|
ran: ywb dfi lwa
|
||||||
|
tyx: ekw tsx byx
|
||||||
|
fkw: ecl nbo snl zxo
|
||||||
|
plk: mll zgr
|
||||||
|
zap: fdb swd
|
||||||
|
jaq: fzw
|
||||||
|
ljw: tsx hrv ekw
|
||||||
|
aqi: yia mwt
|
||||||
|
vrk: lrp yjs yfn
|
||||||
|
ekw: tiv jsy fzw ogp
|
||||||
|
dxi: drg xml
|
||||||
|
sbb: wdd kcc vyz fgd zpe ggt mkm ftk sxu ran bon ogj txq qpc pmq myt blb vrb
|
||||||
|
hsh: xku bxw wmu sbb grm
|
||||||
|
yey: okt
|
||||||
10
src/exercises/assets/day_11_test_input.txt
Normal file
10
src/exercises/assets/day_11_test_input.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
aaa: you hhh
|
||||||
|
you: bbb ccc
|
||||||
|
bbb: ddd eee
|
||||||
|
ccc: ddd eee fff
|
||||||
|
ddd: ggg
|
||||||
|
eee: out
|
||||||
|
fff: out
|
||||||
|
ggg: out
|
||||||
|
hhh: ccc fff iii
|
||||||
|
iii: out
|
||||||
33
src/exercises/assets/day_12_test_input.txt
Normal file
33
src/exercises/assets/day_12_test_input.txt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
0:
|
||||||
|
###
|
||||||
|
##.
|
||||||
|
##.
|
||||||
|
|
||||||
|
1:
|
||||||
|
###
|
||||||
|
##.
|
||||||
|
.##
|
||||||
|
|
||||||
|
2:
|
||||||
|
.##
|
||||||
|
###
|
||||||
|
##.
|
||||||
|
|
||||||
|
3:
|
||||||
|
##.
|
||||||
|
###
|
||||||
|
##.
|
||||||
|
|
||||||
|
4:
|
||||||
|
###
|
||||||
|
#..
|
||||||
|
###
|
||||||
|
|
||||||
|
5:
|
||||||
|
###
|
||||||
|
.#.
|
||||||
|
###
|
||||||
|
|
||||||
|
4x4: 0 0 0 0 2 0
|
||||||
|
12x5: 1 0 1 0 2 2
|
||||||
|
12x5: 1 0 1 0 3 2
|
||||||
496
src/exercises/assets/day_9_input.txt
Normal file
496
src/exercises/assets/day_9_input.txt
Normal file
@@ -0,0 +1,496 @@
|
|||||||
|
97918,50201
|
||||||
|
97918,51425
|
||||||
|
98247,51425
|
||||||
|
98247,52647
|
||||||
|
98195,52647
|
||||||
|
98195,53859
|
||||||
|
98005,53859
|
||||||
|
98005,55071
|
||||||
|
97872,55071
|
||||||
|
97872,56297
|
||||||
|
97835,56297
|
||||||
|
97835,57522
|
||||||
|
97759,57522
|
||||||
|
97759,58659
|
||||||
|
97171,58659
|
||||||
|
97171,59849
|
||||||
|
96924,59849
|
||||||
|
96924,61075
|
||||||
|
96832,61075
|
||||||
|
96832,62278
|
||||||
|
96613,62278
|
||||||
|
96613,63385
|
||||||
|
96045,63385
|
||||||
|
96045,64538
|
||||||
|
95663,64538
|
||||||
|
95663,65837
|
||||||
|
95705,65837
|
||||||
|
95705,66999
|
||||||
|
95314,66999
|
||||||
|
95314,68121
|
||||||
|
94816,68121
|
||||||
|
94816,69159
|
||||||
|
94132,69159
|
||||||
|
94132,70235
|
||||||
|
93557,70235
|
||||||
|
93557,71392
|
||||||
|
93150,71392
|
||||||
|
93150,72594
|
||||||
|
92813,72594
|
||||||
|
92813,73464
|
||||||
|
91858,73464
|
||||||
|
91858,74283
|
||||||
|
90857,74283
|
||||||
|
90857,75827
|
||||||
|
91050,75827
|
||||||
|
91050,76622
|
||||||
|
90026,76622
|
||||||
|
90026,77623
|
||||||
|
89334,77623
|
||||||
|
89334,78461
|
||||||
|
88419,78461
|
||||||
|
88419,79592
|
||||||
|
87898,79592
|
||||||
|
87898,80529
|
||||||
|
87121,80529
|
||||||
|
87121,81258
|
||||||
|
86103,81258
|
||||||
|
86103,82506
|
||||||
|
85676,82506
|
||||||
|
85676,82951
|
||||||
|
84373,82951
|
||||||
|
84373,84417
|
||||||
|
84129,84417
|
||||||
|
84129,84738
|
||||||
|
82744,84738
|
||||||
|
82744,85431
|
||||||
|
81740,85431
|
||||||
|
81740,86272
|
||||||
|
80874,86272
|
||||||
|
80874,86984
|
||||||
|
79898,86984
|
||||||
|
79898,87707
|
||||||
|
78934,87707
|
||||||
|
78934,88651
|
||||||
|
78132,88651
|
||||||
|
78132,89825
|
||||||
|
77471,89825
|
||||||
|
77471,90048
|
||||||
|
76152,90048
|
||||||
|
76152,91026
|
||||||
|
75332,91026
|
||||||
|
75332,91113
|
||||||
|
73969,91113
|
||||||
|
73969,92433
|
||||||
|
73319,92433
|
||||||
|
73319,92653
|
||||||
|
72052,92653
|
||||||
|
72052,92817
|
||||||
|
70779,92817
|
||||||
|
70779,93561
|
||||||
|
69793,93561
|
||||||
|
69793,94429
|
||||||
|
68844,94429
|
||||||
|
68844,94816
|
||||||
|
67683,94816
|
||||||
|
67683,94825
|
||||||
|
66387,94825
|
||||||
|
66387,95504
|
||||||
|
65340,95504
|
||||||
|
65340,96215
|
||||||
|
64286,96215
|
||||||
|
64286,95778
|
||||||
|
62890,95778
|
||||||
|
62890,96609
|
||||||
|
61858,96609
|
||||||
|
61858,97235
|
||||||
|
60751,97235
|
||||||
|
60751,97506
|
||||||
|
59554,97506
|
||||||
|
59554,97496
|
||||||
|
58306,97496
|
||||||
|
58306,97162
|
||||||
|
57021,97162
|
||||||
|
57021,97638
|
||||||
|
55863,97638
|
||||||
|
55863,98017
|
||||||
|
54678,98017
|
||||||
|
54678,98087
|
||||||
|
53458,98087
|
||||||
|
53458,98404
|
||||||
|
52250,98404
|
||||||
|
52250,98467
|
||||||
|
51023,98467
|
||||||
|
51023,97591
|
||||||
|
49799,97591
|
||||||
|
49799,97549
|
||||||
|
48594,97549
|
||||||
|
48594,97447
|
||||||
|
47393,97447
|
||||||
|
47393,97559
|
||||||
|
46176,97559
|
||||||
|
46176,97590
|
||||||
|
44957,97590
|
||||||
|
44957,97139
|
||||||
|
43794,97139
|
||||||
|
43794,97718
|
||||||
|
42484,97718
|
||||||
|
42484,97235
|
||||||
|
41328,97235
|
||||||
|
41328,97025
|
||||||
|
40129,97025
|
||||||
|
40129,96569
|
||||||
|
38986,96569
|
||||||
|
38986,96439
|
||||||
|
37767,96439
|
||||||
|
37767,96227
|
||||||
|
36561,96227
|
||||||
|
36561,95775
|
||||||
|
35425,95775
|
||||||
|
35425,95708
|
||||||
|
34160,95708
|
||||||
|
34160,94873
|
||||||
|
33165,94873
|
||||||
|
33165,94442
|
||||||
|
32030,94442
|
||||||
|
32030,93853
|
||||||
|
30961,93853
|
||||||
|
30961,93475
|
||||||
|
29801,93475
|
||||||
|
29801,93145
|
||||||
|
28610,93145
|
||||||
|
28610,92571
|
||||||
|
27533,92571
|
||||||
|
27533,91778
|
||||||
|
26580,91778
|
||||||
|
26580,91054
|
||||||
|
25599,91054
|
||||||
|
25599,90700
|
||||||
|
24392,90700
|
||||||
|
24392,90098
|
||||||
|
23330,90098
|
||||||
|
23330,89610
|
||||||
|
22181,89610
|
||||||
|
22181,88575
|
||||||
|
21422,88575
|
||||||
|
21422,87836
|
||||||
|
20456,87836
|
||||||
|
20456,87257
|
||||||
|
19358,87257
|
||||||
|
19358,86584
|
||||||
|
18325,86584
|
||||||
|
18325,85761
|
||||||
|
17416,85761
|
||||||
|
17416,84396
|
||||||
|
17026,84396
|
||||||
|
17026,83497
|
||||||
|
16219,83497
|
||||||
|
16219,82724
|
||||||
|
15282,82724
|
||||||
|
15282,81812
|
||||||
|
14488,81812
|
||||||
|
14488,81287
|
||||||
|
13242,81287
|
||||||
|
13242,80044
|
||||||
|
12835,80044
|
||||||
|
12835,79273
|
||||||
|
11850,79273
|
||||||
|
11850,78300
|
||||||
|
11117,78300
|
||||||
|
11117,77140
|
||||||
|
10654,77140
|
||||||
|
10654,76100
|
||||||
|
10032,76100
|
||||||
|
10032,75292
|
||||||
|
9038,75292
|
||||||
|
9038,74404
|
||||||
|
8140,74404
|
||||||
|
8140,73087
|
||||||
|
7988,73087
|
||||||
|
7988,71995
|
||||||
|
7455,71995
|
||||||
|
7455,71036
|
||||||
|
6653,71036
|
||||||
|
6653,69869
|
||||||
|
6271,69869
|
||||||
|
6271,68669
|
||||||
|
5984,68669
|
||||||
|
5984,67752
|
||||||
|
5008,67752
|
||||||
|
5008,66446
|
||||||
|
5011,66446
|
||||||
|
5011,65435
|
||||||
|
4213,65435
|
||||||
|
4213,64209
|
||||||
|
4035,64209
|
||||||
|
4035,63114
|
||||||
|
3426,63114
|
||||||
|
3426,61827
|
||||||
|
3512,61827
|
||||||
|
3512,60715
|
||||||
|
2925,60715
|
||||||
|
2925,59521
|
||||||
|
2657,59521
|
||||||
|
2657,58341
|
||||||
|
2305,58341
|
||||||
|
2305,57063
|
||||||
|
2555,57063
|
||||||
|
2555,55868
|
||||||
|
2321,55868
|
||||||
|
2321,54631
|
||||||
|
2469,54631
|
||||||
|
2469,53453
|
||||||
|
1978,53453
|
||||||
|
1978,52239
|
||||||
|
1840,52239
|
||||||
|
1840,51023
|
||||||
|
1568,51023
|
||||||
|
1568,50187
|
||||||
|
94581,50187
|
||||||
|
94581,48595
|
||||||
|
2489,48595
|
||||||
|
2489,47360
|
||||||
|
1948,47360
|
||||||
|
1948,46149
|
||||||
|
2099,46149
|
||||||
|
2099,44932
|
||||||
|
2173,44932
|
||||||
|
2173,43745
|
||||||
|
2490,43745
|
||||||
|
2490,42544
|
||||||
|
2663,42544
|
||||||
|
2663,41373
|
||||||
|
3007,41373
|
||||||
|
3007,40066
|
||||||
|
2674,40066
|
||||||
|
2674,39008
|
||||||
|
3523,39008
|
||||||
|
3523,37778
|
||||||
|
3604,37778
|
||||||
|
3604,36502
|
||||||
|
3567,36502
|
||||||
|
3567,35540
|
||||||
|
4584,35540
|
||||||
|
4584,34126
|
||||||
|
4191,34126
|
||||||
|
4191,33194
|
||||||
|
5204,33194
|
||||||
|
5204,32063
|
||||||
|
5639,32063
|
||||||
|
5639,30930
|
||||||
|
6073,30930
|
||||||
|
6073,29848
|
||||||
|
6623,29848
|
||||||
|
6623,28717
|
||||||
|
7070,28717
|
||||||
|
7070,27492
|
||||||
|
7350,27492
|
||||||
|
7350,26613
|
||||||
|
8281,26613
|
||||||
|
8281,25390
|
||||||
|
8594,25390
|
||||||
|
8594,24514
|
||||||
|
9492,24514
|
||||||
|
9492,23522
|
||||||
|
10191,23522
|
||||||
|
10191,22173
|
||||||
|
10377,22173
|
||||||
|
10377,21180
|
||||||
|
11097,21180
|
||||||
|
11097,20343
|
||||||
|
12018,20343
|
||||||
|
12018,19523
|
||||||
|
12942,19523
|
||||||
|
12942,18816
|
||||||
|
13983,18816
|
||||||
|
13983,17981
|
||||||
|
14858,17981
|
||||||
|
14858,16809
|
||||||
|
15376,16809
|
||||||
|
15376,16068
|
||||||
|
16353,16068
|
||||||
|
16353,15030
|
||||||
|
17038,15030
|
||||||
|
17038,14301
|
||||||
|
18019,14301
|
||||||
|
18019,13410
|
||||||
|
18855,13410
|
||||||
|
18855,12559
|
||||||
|
19733,12559
|
||||||
|
19733,12152
|
||||||
|
20957,12152
|
||||||
|
20957,10852
|
||||||
|
21506,10852
|
||||||
|
21506,10788
|
||||||
|
22952,10788
|
||||||
|
22952,9988
|
||||||
|
23871,9988
|
||||||
|
23871,8781
|
||||||
|
24548,8781
|
||||||
|
24548,8442
|
||||||
|
25771,8442
|
||||||
|
25771,7748
|
||||||
|
26780,7748
|
||||||
|
26780,7638
|
||||||
|
28098,7638
|
||||||
|
28098,6597
|
||||||
|
28936,6597
|
||||||
|
28936,6634
|
||||||
|
30295,6634
|
||||||
|
30295,5530
|
||||||
|
31137,5530
|
||||||
|
31137,5119
|
||||||
|
32291,5119
|
||||||
|
32291,5171
|
||||||
|
33611,5171
|
||||||
|
33611,4750
|
||||||
|
34745,4750
|
||||||
|
34745,4394
|
||||||
|
35901,4394
|
||||||
|
35901,4192
|
||||||
|
37101,4192
|
||||||
|
37101,3248
|
||||||
|
38105,3248
|
||||||
|
38105,3209
|
||||||
|
39349,3209
|
||||||
|
39349,2909
|
||||||
|
40529,2909
|
||||||
|
40529,2965
|
||||||
|
41774,2965
|
||||||
|
41774,2208
|
||||||
|
42884,2208
|
||||||
|
42884,2578
|
||||||
|
44163,2578
|
||||||
|
44163,2700
|
||||||
|
45391,2700
|
||||||
|
45391,1938
|
||||||
|
46543,1938
|
||||||
|
46543,2387
|
||||||
|
47786,2387
|
||||||
|
47786,2473
|
||||||
|
48995,2473
|
||||||
|
48995,2002
|
||||||
|
50202,2002
|
||||||
|
50202,1582
|
||||||
|
51430,1582
|
||||||
|
51430,1775
|
||||||
|
52649,1775
|
||||||
|
52649,2210
|
||||||
|
53841,2210
|
||||||
|
53841,2166
|
||||||
|
55067,2166
|
||||||
|
55067,2369
|
||||||
|
56270,2369
|
||||||
|
56270,2715
|
||||||
|
57447,2715
|
||||||
|
57447,2376
|
||||||
|
58742,2376
|
||||||
|
58742,3117
|
||||||
|
59840,3117
|
||||||
|
59840,2894
|
||||||
|
61140,2894
|
||||||
|
61140,3742
|
||||||
|
62185,3742
|
||||||
|
62185,3817
|
||||||
|
63425,3817
|
||||||
|
63425,3989
|
||||||
|
64648,3989
|
||||||
|
64648,5057
|
||||||
|
65573,5057
|
||||||
|
65573,4922
|
||||||
|
66910,4922
|
||||||
|
66910,5185
|
||||||
|
68120,5185
|
||||||
|
68120,5964
|
||||||
|
69117,5964
|
||||||
|
69117,6674
|
||||||
|
70128,6674
|
||||||
|
70128,6710
|
||||||
|
71460,6710
|
||||||
|
71460,7450
|
||||||
|
72454,7450
|
||||||
|
72454,8385
|
||||||
|
73327,8385
|
||||||
|
73327,8392
|
||||||
|
74729,8392
|
||||||
|
74729,9508
|
||||||
|
75475,9508
|
||||||
|
75475,10041
|
||||||
|
76576,10041
|
||||||
|
76576,10869
|
||||||
|
77480,10869
|
||||||
|
77480,11720
|
||||||
|
78357,11720
|
||||||
|
78357,12429
|
||||||
|
79335,12429
|
||||||
|
79335,12852
|
||||||
|
80550,12852
|
||||||
|
80550,13833
|
||||||
|
81313,13833
|
||||||
|
81313,14720
|
||||||
|
82144,14720
|
||||||
|
82144,15684
|
||||||
|
82895,15684
|
||||||
|
82895,16530
|
||||||
|
83752,16530
|
||||||
|
83752,17162
|
||||||
|
84838,17162
|
||||||
|
84838,17952
|
||||||
|
85773,17952
|
||||||
|
85773,18787
|
||||||
|
86668,18787
|
||||||
|
86668,19898
|
||||||
|
87235,19898
|
||||||
|
87235,20534
|
||||||
|
88399,20534
|
||||||
|
88399,21819
|
||||||
|
88718,21819
|
||||||
|
88718,22937
|
||||||
|
89233,22937
|
||||||
|
89233,23968
|
||||||
|
89861,23968
|
||||||
|
89861,24660
|
||||||
|
91036,24660
|
||||||
|
91036,25849
|
||||||
|
91424,25849
|
||||||
|
91424,26916
|
||||||
|
92004,26916
|
||||||
|
92004,27802
|
||||||
|
92933,27802
|
||||||
|
92933,28832
|
||||||
|
93616,28832
|
||||||
|
93616,30336
|
||||||
|
93275,30336
|
||||||
|
93275,31169
|
||||||
|
94394,31169
|
||||||
|
94394,32316
|
||||||
|
94816,32316
|
||||||
|
94816,33403
|
||||||
|
95397,33403
|
||||||
|
95397,34581
|
||||||
|
95737,34581
|
||||||
|
95737,35916
|
||||||
|
95557,35916
|
||||||
|
95557,37120
|
||||||
|
95737,37120
|
||||||
|
95737,38230
|
||||||
|
96258,38230
|
||||||
|
96258,39290
|
||||||
|
97047,39290
|
||||||
|
97047,40627
|
||||||
|
96600,40627
|
||||||
|
96600,41738
|
||||||
|
97237,41738
|
||||||
|
97237,42902
|
||||||
|
97667,42902
|
||||||
|
97667,44190
|
||||||
|
97201,44190
|
||||||
|
97201,45331
|
||||||
|
97913,45331
|
||||||
|
97913,46539
|
||||||
|
98110,46539
|
||||||
|
98110,47754
|
||||||
|
98296,47754
|
||||||
|
98296,48987
|
||||||
|
97943,48987
|
||||||
|
97943,50201
|
||||||
8
src/exercises/assets/day_9_test_input.txt
Normal file
8
src/exercises/assets/day_9_test_input.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
7,1
|
||||||
|
11,1
|
||||||
|
11,7
|
||||||
|
9,7
|
||||||
|
9,5
|
||||||
|
2,5
|
||||||
|
2,3
|
||||||
|
7,3
|
||||||
251
src/exercises/day_10.ts
Normal file
251
src/exercises/day_10.ts
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
enum Indicator {
|
||||||
|
ON = "#",
|
||||||
|
OFF = ".",
|
||||||
|
}
|
||||||
|
|
||||||
|
type ButtonWiring = number[];
|
||||||
|
type Joltage = number;
|
||||||
|
|
||||||
|
interface MachineManual {
|
||||||
|
indicators: Indicator[];
|
||||||
|
button_wirings: ButtonWiring[];
|
||||||
|
joltage_requirements: Joltage[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function Factory() {
|
||||||
|
console.log("== Factory ==");
|
||||||
|
const manual_list = await read_machine_manuals_quick(
|
||||||
|
"src/exercises/assets/day_10_input.txt",
|
||||||
|
);
|
||||||
|
const min_presses = count_min_button_presses(manual_list);
|
||||||
|
console.log(
|
||||||
|
">> Min button presses to start: ",
|
||||||
|
min_presses,
|
||||||
|
);
|
||||||
|
const min_joltage_presses = count_min_button_presses_joltage(manual_list);
|
||||||
|
console.log(
|
||||||
|
">> Min button presses to function: ",
|
||||||
|
min_joltage_presses,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function count_min_button_presses(manuals: MachineManual[]): number {
|
||||||
|
let total_sum = 0;
|
||||||
|
manuals.forEach((manual) => {
|
||||||
|
const wiring_list = manual.button_wirings;
|
||||||
|
|
||||||
|
let min_presses = Infinity;
|
||||||
|
|
||||||
|
for (let size = 1; size < wiring_list.length; size++) {
|
||||||
|
const button_combinations = make_all_combinations_of_size(
|
||||||
|
wiring_list,
|
||||||
|
size,
|
||||||
|
);
|
||||||
|
button_combinations.forEach((combination) => {
|
||||||
|
// Apply combination
|
||||||
|
let pairing_indicator = manual.indicators.map((_) => Indicator.OFF);
|
||||||
|
combination.forEach((b) => {
|
||||||
|
pairing_indicator = apply_wiring_to_indicators(
|
||||||
|
b,
|
||||||
|
pairing_indicator,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if valid
|
||||||
|
if (pairing_indicator.join("") === manual.indicators.join("")) {
|
||||||
|
min_presses = combination.length;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (min_presses < Infinity) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
total_sum += min_presses;
|
||||||
|
});
|
||||||
|
|
||||||
|
return total_sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function count_min_button_presses_joltage(
|
||||||
|
manuals: MachineManual[],
|
||||||
|
): number {
|
||||||
|
let total_sum = 0;
|
||||||
|
manuals.forEach((manual) => {
|
||||||
|
const wiring_list = manual.button_wirings;
|
||||||
|
const target_joltage = manual.joltage_requirements;
|
||||||
|
|
||||||
|
// FIXME: calc max possible size
|
||||||
|
const MAX_SIZE = 8;
|
||||||
|
const combination_list = make_all_combinations_repeating(
|
||||||
|
wiring_list,
|
||||||
|
MAX_SIZE,
|
||||||
|
);
|
||||||
|
|
||||||
|
let min_presses = Infinity;
|
||||||
|
combination_list.forEach((combination) => {
|
||||||
|
// Apply combinations
|
||||||
|
let joltage_indicator = manual.joltage_requirements.map((_) => 0);
|
||||||
|
combination.forEach((c, i) => {
|
||||||
|
for (let j = 0; j < c; j++) {
|
||||||
|
joltage_indicator = apply_wiring_to_joltage(
|
||||||
|
wiring_list[i],
|
||||||
|
joltage_indicator,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const combination_size = combination.reduce(
|
||||||
|
(prev, current) => current + prev,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
// Update manual min
|
||||||
|
if (
|
||||||
|
target_joltage.join("") === joltage_indicator.join("") &&
|
||||||
|
min_presses > combination_size
|
||||||
|
) {
|
||||||
|
min_presses = combination_size;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
total_sum += min_presses;
|
||||||
|
});
|
||||||
|
|
||||||
|
return total_sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply_wiring_to_indicators(
|
||||||
|
wiring: ButtonWiring,
|
||||||
|
indicator: Indicator[],
|
||||||
|
): Indicator[] {
|
||||||
|
return indicator.map((w, i) =>
|
||||||
|
wiring.includes(i) ? w === Indicator.ON ? Indicator.OFF : Indicator.ON : w
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply_wiring_to_joltage(
|
||||||
|
wiring: ButtonWiring,
|
||||||
|
joltage: Joltage[],
|
||||||
|
): Joltage[] {
|
||||||
|
return joltage.map((j, i) => wiring.includes(i) ? j + 1 : j);
|
||||||
|
}
|
||||||
|
|
||||||
|
function make_all_combinations_of_size<T extends unknown[]>(
|
||||||
|
list: T,
|
||||||
|
size: number,
|
||||||
|
): T[] {
|
||||||
|
const binary_cap = Math.pow(2, list.length);
|
||||||
|
|
||||||
|
const result_list: T[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < binary_cap; i++) {
|
||||||
|
const combination = i.toString(2).padStart(list.length, "0").split("");
|
||||||
|
|
||||||
|
if (
|
||||||
|
combination.reduce((sum, n) => sum + (n === "1" ? 1 : 0), 0) !== size
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const next_l = list.map((l, i) => combination[i] === "1" ? l : null).filter(
|
||||||
|
(l) => l !== null,
|
||||||
|
);
|
||||||
|
result_list.push(next_l as T);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function make_all_combinations_repeating<T extends unknown[]>(
|
||||||
|
list: T,
|
||||||
|
max_repetitions: number,
|
||||||
|
): number[][] {
|
||||||
|
const binary_base = max_repetitions + 1;
|
||||||
|
const binary_cap = Math.pow(binary_base, list.length);
|
||||||
|
|
||||||
|
const result_list: number[][] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < binary_cap; i++) {
|
||||||
|
const combination = i.toString(binary_base).padStart(list.length, "0")
|
||||||
|
.split("");
|
||||||
|
|
||||||
|
result_list.push(combination.map((c) => parseInt(c, binary_base)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function read_machine_manuals(
|
||||||
|
path: string,
|
||||||
|
): Promise<MachineManual[]> {
|
||||||
|
const line_regex = /\[([.#]+)\] (.*)+ \{(.*)\}/g;
|
||||||
|
const input_txt = await Deno.readTextFile(path);
|
||||||
|
const lines = input_txt.split("\n");
|
||||||
|
|
||||||
|
const manual_list: MachineManual[] = lines.map((line) => {
|
||||||
|
const matched_line = line.matchAll(line_regex)?.toArray()?.[0];
|
||||||
|
if (matched_line && matched_line.length > 3) {
|
||||||
|
const indicators = matched_line[1].toString().split("").map((ch) =>
|
||||||
|
ch === Indicator.ON ? Indicator.ON : Indicator.OFF
|
||||||
|
);
|
||||||
|
const buttons = matched_line[2].split(" ").map((b) =>
|
||||||
|
b.replaceAll("(", "").replaceAll(")", "").split(",").map((n) =>
|
||||||
|
parseInt(n)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const joltages = matched_line[3].split(",").map((j) => parseInt(j));
|
||||||
|
return {
|
||||||
|
indicators,
|
||||||
|
button_wirings: buttons,
|
||||||
|
joltage_requirements: joltages,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}).filter((v) => v !== null);
|
||||||
|
|
||||||
|
return manual_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function read_machine_manuals_quick(
|
||||||
|
path: string,
|
||||||
|
): Promise<MachineManual[]> {
|
||||||
|
const input_txt = await Deno.readTextFile(path);
|
||||||
|
const lines = input_txt.split("\n");
|
||||||
|
|
||||||
|
const manual_list: MachineManual[] = [];
|
||||||
|
|
||||||
|
lines.forEach((line, line_i) => {
|
||||||
|
const manual: MachineManual = {
|
||||||
|
indicators: [],
|
||||||
|
button_wirings: [],
|
||||||
|
joltage_requirements: [],
|
||||||
|
};
|
||||||
|
line.split(" ").forEach((element) => {
|
||||||
|
if (element.includes("[")) {
|
||||||
|
manual.indicators = element.replaceAll("[", "").replaceAll("]", "")
|
||||||
|
.split("").map((e) => e as Indicator);
|
||||||
|
} else if (element.includes("{")) {
|
||||||
|
manual.joltage_requirements = element.replaceAll("{", "").replaceAll(
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
).split(",").map((e) => parseInt(e));
|
||||||
|
} else if (element.includes("(")) {
|
||||||
|
manual.button_wirings.push(
|
||||||
|
element.replaceAll("(", "").replaceAll(")", "").split(",").map((e) =>
|
||||||
|
parseInt(e)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (
|
||||||
|
manual.button_wirings.length > 0 &&
|
||||||
|
manual.joltage_requirements.length > 0 && manual.indicators.length > 0
|
||||||
|
) {
|
||||||
|
manual_list.push(manual);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return manual_list;
|
||||||
|
}
|
||||||
81
src/exercises/day_11.ts
Normal file
81
src/exercises/day_11.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
const INIT = "you";
|
||||||
|
const END = "out";
|
||||||
|
type Device = {
|
||||||
|
name: string;
|
||||||
|
output_list: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default async function Reactor() {
|
||||||
|
const input_list = await read_device_list(
|
||||||
|
"src/exercises/assets/day_11_input.txt",
|
||||||
|
);
|
||||||
|
const path_count = count_all_out_paths(input_list, "you");
|
||||||
|
console.log(">> The number of paths is: ", path_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function count_all_out_paths(list: Device[], init: string): number {
|
||||||
|
let total = 0;
|
||||||
|
const current_device = list.find((d) => d.name === init);
|
||||||
|
|
||||||
|
// Default exits
|
||||||
|
// NOTE: how to avoid circular connections
|
||||||
|
if (!current_device) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (current_device.output_list.length < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (current_device.output_list.includes(END)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_device.output_list.forEach((output) => {
|
||||||
|
total += count_all_out_paths(list, output);
|
||||||
|
});
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
// const REQUIREMENT_1 = "fft";
|
||||||
|
// const REQUIREMENT_2 = "dac";
|
||||||
|
// export function find_all_out_complex_paths(
|
||||||
|
// list: Device[],
|
||||||
|
// init: string,
|
||||||
|
// path: string[],
|
||||||
|
// ): string[][] {
|
||||||
|
// let total = 0;
|
||||||
|
// const current_device = list.find((d) => d.name === init);
|
||||||
|
//
|
||||||
|
// // Default exits
|
||||||
|
// // NOTE: how to avoid circular connections
|
||||||
|
// if (!current_device) {
|
||||||
|
// return [];
|
||||||
|
// }
|
||||||
|
// if (current_device.output_list.length < 1) {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
// if (current_device.output_list.includes(END)) {
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// current_device.output_list.forEach((output) => {
|
||||||
|
// total += count_all_out_paths(list, output);
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// return total;
|
||||||
|
// }
|
||||||
|
|
||||||
|
export async function read_device_list(path: string): Promise<Device[]> {
|
||||||
|
const txt_file = await Deno.readTextFile(path);
|
||||||
|
const raw_device_list = txt_file.split("\n");
|
||||||
|
|
||||||
|
return raw_device_list.filter((d) => !!d).map((device) => {
|
||||||
|
const [name, raw_outputs] = device.split(": ");
|
||||||
|
const output_list = raw_outputs.split(" ");
|
||||||
|
const formatted_device: Device = {
|
||||||
|
name,
|
||||||
|
output_list,
|
||||||
|
};
|
||||||
|
return formatted_device;
|
||||||
|
});
|
||||||
|
}
|
||||||
88
src/exercises/day_12.ts
Normal file
88
src/exercises/day_12.ts
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
enum Point {
|
||||||
|
FILLED = "#",
|
||||||
|
EMPTY = ".",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Present = Point[][];
|
||||||
|
type Region = {
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
};
|
||||||
|
interface Tree {
|
||||||
|
region: Region;
|
||||||
|
presents: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SituationSummary {
|
||||||
|
presents: Present[];
|
||||||
|
trees: Tree[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function ChristmasTreeFarm() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_presents_fit(tree: Tree, presents: Present[]): boolean {
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_present_pair_fit(tree: Tree, p_a: Present, p_b: Present): boolean {
|
||||||
|
}
|
||||||
|
|
||||||
|
function rotate_present_90_deg(present: Present): Present {
|
||||||
|
}
|
||||||
|
|
||||||
|
function flip_present_horizontal(present: Present): Present {
|
||||||
|
}
|
||||||
|
|
||||||
|
function flip_present_vertical(present: Present): Present {
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function read_situation_summary(
|
||||||
|
path: string,
|
||||||
|
): Promise<SituationSummary> {
|
||||||
|
const txt_input = await Deno.readTextFile(path);
|
||||||
|
// NOTE: should be done with splits to avoid performance issues on final sample
|
||||||
|
const block_list = txt_input.split("\n\n");
|
||||||
|
|
||||||
|
const present_list: Present[] = [];
|
||||||
|
const tree_list: Tree[] = [];
|
||||||
|
|
||||||
|
block_list.forEach((block) => {
|
||||||
|
if (block.includes("x")) {
|
||||||
|
// Tree
|
||||||
|
const raw_trees = block.split("\n");
|
||||||
|
raw_trees.forEach((t) => {
|
||||||
|
if (!t || t.length < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const [raw_region, raw_presents] = t.split(": ");
|
||||||
|
const region: Tree["region"] = {
|
||||||
|
width: parseInt(raw_region.split("x")[0]),
|
||||||
|
height: parseInt(raw_region.split("x")[1]),
|
||||||
|
};
|
||||||
|
const presents: Tree["presents"] = raw_presents.split(" ").map((p) => {
|
||||||
|
const p_n = parseInt(p);
|
||||||
|
if (p_n === p_n) {
|
||||||
|
return p_n;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}).filter((p) => p !== undefined);
|
||||||
|
|
||||||
|
tree_list.push({ region, presents });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Present
|
||||||
|
const raw_present = block.split("\n").slice(1);
|
||||||
|
const present: Present = raw_present.map((line) =>
|
||||||
|
line.split("").map((p) =>
|
||||||
|
p === Point.FILLED ? Point.FILLED : Point.EMPTY
|
||||||
|
)
|
||||||
|
);
|
||||||
|
present_list.push(present);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
presents: present_list,
|
||||||
|
trees: tree_list,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -12,6 +12,10 @@ export default async function Playground() {
|
|||||||
">> Three largest pairings mul: ",
|
">> Three largest pairings mul: ",
|
||||||
get_three_largest_pairings_mul(junction_boxes_coords, 1000),
|
get_three_largest_pairings_mul(junction_boxes_coords, 1000),
|
||||||
);
|
);
|
||||||
|
console.log(
|
||||||
|
">> Last pairing mul: ",
|
||||||
|
get_last_pairing_mul(junction_boxes_coords),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_three_largest_pairings_mul(
|
export function get_three_largest_pairings_mul(
|
||||||
@@ -28,11 +32,26 @@ export function get_three_largest_pairings_mul(
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function get_last_pairing_mul(box_list: Coordinate[]): number {
|
||||||
|
const last_pairing = get_last_pairing_circuit(box_list);
|
||||||
|
if (last_pairing) {
|
||||||
|
return box_list[last_pairing.a].x * box_list[last_pairing.b].x;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DistancePairing {
|
||||||
|
a: number;
|
||||||
|
b: number;
|
||||||
|
distance: number;
|
||||||
|
}
|
||||||
|
|
||||||
function generate_n_shortest_distances(
|
function generate_n_shortest_distances(
|
||||||
box_list: Coordinate[],
|
box_list: Coordinate[],
|
||||||
n: number,
|
n: number,
|
||||||
): { a: number; b: number; distance: number }[] {
|
initial_distances?: DistancePairing[],
|
||||||
const distances: { a: number; b: number; distance: number }[] = [];
|
): DistancePairing[] {
|
||||||
|
const distances: DistancePairing[] = initial_distances ?? [];
|
||||||
for (let i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
const shortest_distance: { distance: number; pair_index: number[] } = {
|
const shortest_distance: { distance: number; pair_index: number[] } = {
|
||||||
distance: Infinity, // Dirty, but it's late
|
distance: Infinity, // Dirty, but it's late
|
||||||
@@ -45,7 +64,10 @@ function generate_n_shortest_distances(
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
next_distance < shortest_distance.distance &&
|
next_distance < shortest_distance.distance &&
|
||||||
!distances.some((d) => d.a === box_index && d.b === next_i)
|
!distances.some((d) =>
|
||||||
|
(d.a === box_index && d.b === next_i) ||
|
||||||
|
(d.b === box_index && d.a === next_i)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
shortest_distance.distance = next_distance;
|
shortest_distance.distance = next_distance;
|
||||||
shortest_distance.pair_index = [box_index, next_i];
|
shortest_distance.pair_index = [box_index, next_i];
|
||||||
@@ -67,99 +89,68 @@ function generate_n_shortest_pairings(
|
|||||||
max_pairings: number,
|
max_pairings: number,
|
||||||
): number[][] {
|
): number[][] {
|
||||||
const distance_list = generate_n_shortest_distances(box_list, max_pairings);
|
const distance_list = generate_n_shortest_distances(box_list, max_pairings);
|
||||||
const circuits: number[][] = [];
|
const circuits: number[][] = box_list.map((_, i) => [i]);
|
||||||
|
|
||||||
distance_list.forEach((distance) => {
|
distance_list.forEach((distance) => {
|
||||||
const a = circuits.find((c) => c.includes(distance.a));
|
const a = circuits.find((c) => c.includes(distance.a));
|
||||||
let b = circuits.find((c) => c.includes(distance.b));
|
const b = circuits.find((c) => c.includes(distance.b));
|
||||||
|
|
||||||
if (a && b) {
|
if (a?.length && b?.length && a !== b) {
|
||||||
|
const to_empty_index = circuits.findIndex((c) => c.includes(distance.b));
|
||||||
b.forEach((x) => a.push(x));
|
b.forEach((x) => a.push(x));
|
||||||
b = [];
|
circuits[to_empty_index] = [];
|
||||||
} else if (a) {
|
|
||||||
a.push(distance.b);
|
|
||||||
} else if (b) {
|
|
||||||
b.push(distance.a);
|
|
||||||
} else {
|
|
||||||
circuits.push([distance.a, distance.b]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return circuits;
|
return circuits;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _generate_n_shortest_pairings_old(
|
function get_last_pairing_circuit(
|
||||||
box_list: Coordinate[],
|
box_list: Coordinate[],
|
||||||
max_pairings: number,
|
): DistancePairing | undefined {
|
||||||
): number[][] {
|
const INCREMENT = 10; // NOTE: to adjust computation cost, since the solution is inefficient
|
||||||
const circuits: number[][] = [];
|
const circuits: number[][] = box_list.map((_, i) => [i]);
|
||||||
|
|
||||||
// Pair generation
|
const is_done = (c: number[][]): boolean => {
|
||||||
for (let i = 0; i < max_pairings; i++) {
|
return c.reduce((prev, current) => {
|
||||||
const shortest_distance: { distance: number; pair_index: number[] } = {
|
if (current.length > 0) {
|
||||||
distance: Infinity, // Dirty, but it's late
|
return prev + 1;
|
||||||
pair_index: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
// Pair boxes
|
|
||||||
box_list.forEach((box, box_index) => {
|
|
||||||
for (let next_i = box_index + 1; next_i < box_list.length; next_i++) {
|
|
||||||
const next_box = box_list[next_i];
|
|
||||||
const next_distance = calc_distance(box, next_box);
|
|
||||||
if (
|
|
||||||
next_distance < shortest_distance.distance &&
|
|
||||||
!circuits.some((pairing) =>
|
|
||||||
pairing.includes(box_index) && pairing.includes(next_i)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
shortest_distance.distance = next_distance;
|
|
||||||
shortest_distance.pair_index = [box_index, next_i];
|
|
||||||
}
|
}
|
||||||
|
return prev;
|
||||||
|
}, 0) > 1
|
||||||
|
? false
|
||||||
|
: true;
|
||||||
|
};
|
||||||
|
|
||||||
|
let last_pairing: DistancePairing | undefined;
|
||||||
|
|
||||||
|
let distance_list = generate_n_shortest_distances(box_list, INCREMENT);
|
||||||
|
while (!is_done(circuits)) {
|
||||||
|
distance_list = generate_n_shortest_distances(
|
||||||
|
box_list,
|
||||||
|
INCREMENT,
|
||||||
|
distance_list,
|
||||||
|
);
|
||||||
|
distance_list.forEach((distance) => {
|
||||||
|
const a = circuits.find((c) => c.includes(distance.a));
|
||||||
|
const b = circuits.find((c) => c.includes(distance.b));
|
||||||
|
|
||||||
|
if (a?.length && b?.length && a !== b) {
|
||||||
|
last_pairing = {
|
||||||
|
a: distance.a,
|
||||||
|
b: distance.b,
|
||||||
|
distance: distance.distance,
|
||||||
|
};
|
||||||
|
const to_empty_index = circuits.findIndex((c) =>
|
||||||
|
c.includes(distance.b)
|
||||||
|
);
|
||||||
|
b.forEach((x) => a.push(x));
|
||||||
|
circuits[to_empty_index] = [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Check shortest pairings and then push
|
|
||||||
const a_circiut = circuits.find((c) =>
|
|
||||||
c.includes(shortest_distance.pair_index[0])
|
|
||||||
);
|
|
||||||
const b_circiut = circuits.find((c) =>
|
|
||||||
c.includes(shortest_distance.pair_index[1])
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(">> ", {
|
|
||||||
circuits,
|
|
||||||
a_circiut,
|
|
||||||
b_circiut,
|
|
||||||
new: shortest_distance.pair_index,
|
|
||||||
distance: shortest_distance.distance,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (
|
|
||||||
a_circiut && b_circiut
|
|
||||||
) {
|
|
||||||
const n_index = circuits.findIndex((p) =>
|
|
||||||
p.includes(shortest_distance.pair_index[1])
|
|
||||||
);
|
|
||||||
b_circiut.forEach((b) => {
|
|
||||||
circuits.find((p) => p.includes(shortest_distance.pair_index[0]))
|
|
||||||
?.push(b);
|
|
||||||
});
|
|
||||||
circuits[n_index] = [];
|
|
||||||
} else if (
|
|
||||||
a_circiut
|
|
||||||
) {
|
|
||||||
circuits.find((p) => p.includes(shortest_distance.pair_index[0]))
|
|
||||||
?.push(shortest_distance.pair_index[1]);
|
|
||||||
} else if (
|
|
||||||
b_circiut
|
|
||||||
) {
|
|
||||||
circuits.find((p) => p.includes(shortest_distance.pair_index[1]))
|
|
||||||
?.push(shortest_distance.pair_index[0]);
|
|
||||||
} else {
|
|
||||||
circuits.push(shortest_distance.pair_index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return circuits;
|
return last_pairing;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calc_distance(a: Coordinate, b: Coordinate): number {
|
function calc_distance(a: Coordinate, b: Coordinate): number {
|
||||||
|
|||||||
206
src/exercises/day_9.ts
Normal file
206
src/exercises/day_9.ts
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
interface Coordinate {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Floor {
|
||||||
|
width: number; // x
|
||||||
|
length: number; // y
|
||||||
|
red_tiles: Coordinate[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function MovieTheater() {
|
||||||
|
const floor = await read_tile_floor(
|
||||||
|
"src/exercises/assets/day_9_input.txt",
|
||||||
|
);
|
||||||
|
console.log(">> Largest red-tile area: ", get_largest_area(floor));
|
||||||
|
console.log(
|
||||||
|
">> Largest red-green-tile area: ",
|
||||||
|
get_largest_green_area(floor),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_largest_area(floor: Floor): number {
|
||||||
|
let largest_area: number = 0;
|
||||||
|
floor.red_tiles.forEach((tile, tile_i) => {
|
||||||
|
for (
|
||||||
|
let inner_i = tile_i + 1;
|
||||||
|
inner_i < floor.red_tiles.length;
|
||||||
|
inner_i++
|
||||||
|
) {
|
||||||
|
const inner_tile = floor.red_tiles[inner_i];
|
||||||
|
const height = calc_distance({ x: tile.x, y: tile.y }, {
|
||||||
|
x: tile.x,
|
||||||
|
y: inner_tile.y,
|
||||||
|
});
|
||||||
|
const width = calc_distance({ x: tile.x, y: tile.y }, {
|
||||||
|
x: inner_tile.x,
|
||||||
|
y: tile.y,
|
||||||
|
});
|
||||||
|
const new_area = (width + 1) * (height + 1); // NOTE: +1 to count also the outer tiles
|
||||||
|
if (new_area > largest_area) {
|
||||||
|
largest_area = new_area;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return largest_area;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_largest_green_area(floor: Floor): number {
|
||||||
|
let largest_area: number = 0;
|
||||||
|
floor.red_tiles.forEach((tile, tile_i) => {
|
||||||
|
for (
|
||||||
|
let inner_i = tile_i + 1;
|
||||||
|
inner_i < floor.red_tiles.length;
|
||||||
|
inner_i++
|
||||||
|
) {
|
||||||
|
const inner_tile = floor.red_tiles[inner_i];
|
||||||
|
if (is_area_red_green(floor, tile, inner_tile)) {
|
||||||
|
const height = calc_distance({ x: tile.x, y: tile.y }, {
|
||||||
|
x: tile.x,
|
||||||
|
y: inner_tile.y,
|
||||||
|
});
|
||||||
|
const width = calc_distance({ x: tile.x, y: tile.y }, {
|
||||||
|
x: inner_tile.x,
|
||||||
|
y: tile.y,
|
||||||
|
});
|
||||||
|
const new_area = (width + 1) * (height + 1); // NOTE: +1 to count also the outer tiles
|
||||||
|
if (new_area > largest_area) {
|
||||||
|
largest_area = new_area;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return largest_area;
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_area_red_green(
|
||||||
|
floor: Floor,
|
||||||
|
a: Coordinate,
|
||||||
|
b: Coordinate,
|
||||||
|
): boolean {
|
||||||
|
const max_x = Math.max(a.x, b.x);
|
||||||
|
const max_y = Math.max(a.y, b.y);
|
||||||
|
const min_x = Math.min(a.x, b.x);
|
||||||
|
const min_y = Math.min(a.y, b.y);
|
||||||
|
|
||||||
|
const tl_corner: Coordinate = { x: min_x, y: min_y };
|
||||||
|
const tr_corner: Coordinate = { x: max_x, y: min_y };
|
||||||
|
const bl_corner: Coordinate = { x: min_x, y: max_y };
|
||||||
|
const br_corner: Coordinate = { x: max_x, y: max_y };
|
||||||
|
|
||||||
|
// NOTE: need to check exact pairs, so they create a line somehow
|
||||||
|
// - Every corner is surrounded
|
||||||
|
// - Every surround must form a line
|
||||||
|
// old: Every corner needs to be surrounded
|
||||||
|
// Error 1: 4560365591
|
||||||
|
// Error 2: 248032161
|
||||||
|
// Error 3: 4638219675
|
||||||
|
const { red_tiles: tiles } = floor;
|
||||||
|
|
||||||
|
let first_verify = false;
|
||||||
|
if (
|
||||||
|
tl_corner.x === a.x && tl_corner.y === a.y ||
|
||||||
|
tl_corner.x === b.x && tl_corner.y === b.y
|
||||||
|
) {
|
||||||
|
first_verify = tiles.some((tile) =>
|
||||||
|
tile.x === tl_corner.x && tile.y >= max_y ||
|
||||||
|
tile.x <= min_x && tile.y === max_y
|
||||||
|
) || tiles.some((tile) =>
|
||||||
|
tile.x <= min_x && tile.y <= max_y && tiles.some((tile_2) =>
|
||||||
|
tile_2.y >= max_y && tile_2.x === tile.x
|
||||||
|
)
|
||||||
|
) || tiles.some((tile) =>
|
||||||
|
tile.y >= max_y && tile.x <= min_x && tiles.some((tile_2) =>
|
||||||
|
tile_2.x >= min_x && tile_2.y === tile.y
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
tr_corner.x === a.x && tr_corner.y === a.y ||
|
||||||
|
tr_corner.x === b.x && tr_corner.y === b.y
|
||||||
|
) {
|
||||||
|
first_verify = tiles.some((tile) =>
|
||||||
|
tile.x === tr_corner.x && tile.y >= max_y ||
|
||||||
|
tile.x >= max_x && tile.y === max_y
|
||||||
|
) || tiles.some((tile) =>
|
||||||
|
tile.x >= max_x && tile.y <= max_y && tiles.some((tile_2) =>
|
||||||
|
tile_2.y >= max_y && tile_2.x === tile.x
|
||||||
|
)
|
||||||
|
) || tiles.some((tile) =>
|
||||||
|
tile.y >= max_y && tile.x >= max_x && tiles.some((tile_2) =>
|
||||||
|
tile_2.x <= min_x && tile_2.y === tile.y
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let second_verify = false;
|
||||||
|
if (
|
||||||
|
bl_corner.x === a.x && bl_corner.y === a.y ||
|
||||||
|
bl_corner.x === b.x && bl_corner.y === b.y
|
||||||
|
) {
|
||||||
|
second_verify = tiles.some((tile) =>
|
||||||
|
tile.x === min_x && tile.y <= min_y ||
|
||||||
|
tile.x <= min_x && tile.y === min_y
|
||||||
|
) || tiles.some((tile) =>
|
||||||
|
tile.x <= min_x && tile.y <= min_y && tiles.some((tile_2) =>
|
||||||
|
tile_2.y >= min_y && tile_2.x === tile.x
|
||||||
|
)
|
||||||
|
) || tiles.some((tile) =>
|
||||||
|
tile.y <= min_y && tile.x <= min_x && tiles.some((tile_2) =>
|
||||||
|
tile_2.x >= min_x && tile_2.y === tile.y
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
br_corner.x === a.x && br_corner.y === a.y ||
|
||||||
|
br_corner.x === b.x && br_corner.y === b.y
|
||||||
|
) {
|
||||||
|
second_verify = tiles.some((tile) =>
|
||||||
|
tile.x === tr_corner.x && tile.y <= min_y ||
|
||||||
|
tile.x >= max_x && tile.y === min_y
|
||||||
|
) || tiles.some((tile) =>
|
||||||
|
tile.x >= max_x && tile.y <= min_y && tiles.some((tile_2) =>
|
||||||
|
tile_2.y >= min_y && tile_2.x === tile.x
|
||||||
|
)
|
||||||
|
) || tiles.some((tile) =>
|
||||||
|
tile.y <= min_y && tile.x <= max_x && tiles.some((tile_2) =>
|
||||||
|
tile_2.x >= max_x && tile_2.y === tile.y
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return first_verify && second_verify;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calc_distance(a: Coordinate, b: Coordinate): number {
|
||||||
|
return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function read_tile_floor(path: string): Promise<Floor> {
|
||||||
|
const red_tile_placements_raw = await Deno.readTextFile(path);
|
||||||
|
const floor: Floor = { width: 0, length: 0, red_tiles: [] };
|
||||||
|
const red_tile_pairings = red_tile_placements_raw.split("\n");
|
||||||
|
let max_x = 0;
|
||||||
|
let max_y = 0;
|
||||||
|
red_tile_pairings.map((pairing) => {
|
||||||
|
const [x, y] = pairing.split(",");
|
||||||
|
const x_int = parseInt(x);
|
||||||
|
const y_int = parseInt(y);
|
||||||
|
|
||||||
|
if (x_int === x_int && y_int === y_int) {
|
||||||
|
floor.red_tiles.push({ x: x_int, y: y_int });
|
||||||
|
|
||||||
|
if (x_int > max_x) {
|
||||||
|
max_x = x_int;
|
||||||
|
}
|
||||||
|
if (y_int > max_y) {
|
||||||
|
max_y = y_int;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
floor.width = max_x;
|
||||||
|
floor.length = max_y;
|
||||||
|
|
||||||
|
return floor;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user