added day04a
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -9,6 +9,7 @@ dependencies = [
|
||||
"day01",
|
||||
"day02",
|
||||
"day03",
|
||||
"day04",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -26,6 +27,10 @@ dependencies = [
|
||||
"iter-first-max",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "day04"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "iter-first-max"
|
||||
version = "0.1.2"
|
||||
|
||||
@@ -7,3 +7,4 @@ edition = "2024"
|
||||
day01 = {path = "src/day01"}
|
||||
day02 = {path = "src/day02"}
|
||||
day03 = {path = "src/day03"}
|
||||
day04 = {path = "src/day04"}
|
||||
|
||||
16
README.md
16
README.md
@@ -1,11 +1,13 @@
|
||||
# Advent of Code 2025
|
||||
```bash
|
||||
day01:A => 1150 ( 72us)
|
||||
day01:B => 6738 ( 98us)
|
||||
day02:A => 31839939622 ( 8141us)
|
||||
day02:B => 41662374059 ( 64109us)
|
||||
day03:A => 16812 ( 152us)
|
||||
day03:B => 166345822896410 ( 298us)
|
||||
day01:A => 1150 ( 130us)
|
||||
day01:B => 6738 ( 161us)
|
||||
day02:A => 31839939622 ( 14191us)
|
||||
day02:B => 41662374059 (135384us)
|
||||
day03:A => 16812 ( 154us)
|
||||
day03:B => 166345822896410 ( 356us)
|
||||
day04:A => 1518 ( 304us)
|
||||
day04:B => 0 ( 9us)
|
||||
----------
|
||||
72992us
|
||||
150768us
|
||||
```
|
||||
7
src/day04/Cargo.lock
generated
Normal file
7
src/day04/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "day04"
|
||||
version = "0.1.0"
|
||||
6
src/day04/Cargo.toml
Normal file
6
src/day04/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "day04"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
138
src/day04/input04.txt
Normal file
138
src/day04/input04.txt
Normal file
@@ -0,0 +1,138 @@
|
||||
@@@..@@.@.@@@..@...@@@@.@.@@@..@@.@@@@...@@@@@.@@@.@@@@.@..@@@@....@@@.@@@..@@..@.@@@.@@@@.@.@@@....@@@@@@.@...@.@@@@@.@@.....@@@@@@@.@.@.
|
||||
@@@@..@@@@.@@@@..@.@..@@@@@@@@.@@@@@@@.@.@@@.@..@..@@.@@@@@@..@..@...@@@@@.....@@@@@..@@@.@@@.@.@@@...@..@.@.@.@@@.@@@@@@..@@@@.@@@@@@@@..
|
||||
@.@.@@.@@@.@@@@@@@@@@@@.@..@.@.@@.@..@@..@@@..@@.@@.@.@..@.@@...@@@@@@....@....@....@@.@@.@@@@@@@.@.@...@@@@@@@...@.@@.@..@@@@@.@.@.@@.@@@
|
||||
...@@@@@.@@@@@@@@@@..@@...@..@@@.....@@@@@@....@@.@@@@@@..@@@.@@@@@.@..@@@@.@.@@@@.@@@@@.@@.@@@@@.@@@.@..@@@@@.@@.@.@..@@.@@@.@..@@@...@@@
|
||||
...@@@@@@.@.@@@@@@..@.@@@@@@....@@..@..@@@@@@@@@....@@@@.@.@.@.@@...@@.@.@.@@@..@...@.@@.@..@@@@@.@@@..@@@@@@@@@@@@.@...@@@@@@@..@@@@.@@.@
|
||||
@@@@@...@.@..@@@@..@@@@@@@.@.@@.@..@@@..@@.@@@.@.@@@@@@@@..@@@@.@..@@@@@@@@.....@...@@@@.@@.@.@@...@@@.@.@@@@@@@...@@@@.@@...@@@@....@@..@
|
||||
@@.@@@@..@@....@@@@@@@@@@@..@@@@.@@@@@.@@@@..@.@@@@@@@@@@.@.@@@@@.@.@.@@@@.@@@...@@@@...@@@@.@@.@.@.@@.@.@.@@@.@.@@@@@.@.@@@..@@@@.@@@@.@.
|
||||
@@@@...@.@@.@@..@@@.@.@@@..@@..@@@@@@@@.@@@@....@@@@@..@.@@@@@@.@.@@.@@@@@@.@.@.@@.@@...@..@.@@.@@@@@....@@.@@@@.@@@.@@.@@..@@@@@@.@.@@@@@
|
||||
@@.@@@......@@@.@@.@@.@...@@@.@.@..@@@@@@@@....@@@@.@..@.@@.@@@@.@.@.@.@@@@@@@@@@@.@@.@@..@@.@@@@@@@.@@@@.@@@.@.@.@@@..@@@@@@@.@....@.@@@@
|
||||
.@@...@.@@.@@@@..@@@@.@.@.@...@.@@@@@@.@.@@.@@@.@.@@..@....@.@@.@.@@.@@@@@.@.@@@..@@@.@@.@@@@@@@@.@.@@@@.@@@..@@@..@@@.@@@@@@.@@@@@...@@@.
|
||||
@.@.@@.@@........@.@.@@@@@@@.@..@@.@.@.@.@.@.@.@@@@@...@@.@@@@@@@...@@@..@@.@.@@@@@.@@.@@@@@...@@@.@..@@@@.@@.@.@.@@@...@@.@@@@.@@@@@..@.@
|
||||
@@@@@...@@@@.@.@@@..@@.@@@@.@.@@@@...@@.@@@@@@@@@.@@..@@@@@.@.@@@....@@@@@@..@@..@@@@...@@@@@.@..@@@@@@@.@@@.@...@.@.@.@@@..@@.@.@@@@..@@.
|
||||
@.@.@.@@@@@@.@@@@.@.@@...@@@@@..@@@..@..@@.@.@@@.@@.@.@@@.@@.@..@.@@.@.@@..@.@@.@@@@.@@@@@.@.@@.@..@@@@@@@@@@@@@@...@@@@@@@@.@@@...@@@.@@.
|
||||
@.@.@@@@.@@@@@@@.@@@@..@.@@@@..@@..@@.@.@@@@.@@.@@@@@.@@@..@.@@.@@@.@@@@@@@.@..@.@@@@@.@@@@@..@@@.@@.@@@@.@@@@.@.@@@@@@@@@...@@@@.@@@..@..
|
||||
@@@.@@@.@@@.@@@.@@@.@...@.@.@@..@@.@@@.@@@@....@@@.@..@.@@@@.@@@@..@...@@@@@.@.@...@..@@...@@.@..@.@..@.@@@@.@@@@@@.@@@@.......@@@@@@@@@..
|
||||
...@@@@...@@..@.@@@@.@.@@..@.@..@.@.@@@@@@@@.@@@.@.@@..@.@..@@@.@@@@.@.@@@@@@@.@@...@.@@.@@.@@.@@@@@@@@@.@@@@..@@@.@@@@@.@.@.@@.@..@@@@@@.
|
||||
.@@@@.@@@@@...@@@.@@@@@@@@..@.@@..@@@@@@@@@...@.@.@...@@@@@@@.@@@@@@@..@........@@@@@..@@.....@@...@@@.@@@.@..@...@..@@@@..@.@@@..@@@@.@.@
|
||||
@@@.@@..@..@@@.@.@.@@.@@@@.@@@.@@...@.@..@@@@@@.@.@@.@@@@@.@@....@@@@..@.@@@@.....@@@.@.@.@@@@@@..@@....@@@@@@@@@@@@.@.@@.@@@.@@@@@@@@@@..
|
||||
.@@@.@@.@@@.@@@@.@...@..@@@.@@@..@@@@...@@.@.@@.@@@@..@..@@@@@..@.@..@...@@@@.@@@@.@@..@@@@...@@.@@@.@.@.@@..@..@@.@@@.@@.@@@@@@.@@..@@@.@
|
||||
@.@@@.@..@@@@@@@@@..@.@.@@@@@@@@.@@.@.@@@.@@.@@@@@@@@.@..@@@@.@@.@.....@..@@@@@@@.@@@@.@@@.@.@@@.@.@@@@@...@@@..@@@@@@@@.@.@@@@@.@@.@@@@@@
|
||||
@.@.@.@@@@@@..@..@..@@@.@..@......@@@@..@..@...@@@@@@@@@@@@.@.@.@@..@@@.@@@.@@.@.@.@@@@.@@@@...@.@@@@@@@.@..@@..@.....@@.@@@.@.@@@....@@.@
|
||||
..@@..@@.@@.@.@@@@@.@@..@..@.@.@.@@..@..@.@@@@@@.@.@.@.@@@@@@@@.@@..@@.@@@@.@@@@@@.@@@.@...@@..@@.@@@..@..@..@...@@.@...@.@..@@@@@@.@.@@@@
|
||||
@@@@@@.@@.@@@@..@...@@@@@.@@.@@.@@@@@@.@..@.@@@@...@@.@@@.@@@....@@.@.@@@.@@@.@...@@..@@..@@..@@@@@.@@.@@@@@.@...@@@.@@@.@@.@@@@.@@@.@@.@@
|
||||
@@.@@@@@.@@.@.@.@@@.@.@@...@..@@@@@..@@@@...@@@..@..@@@.@.@.@@@@@.@@.@@@@.@@@..@@@@...@@@@@.@.@@@@.@@@@@@..@@@.@@.@.@....@@@.@@@@@@@.@@@@@
|
||||
.@@@@@@....@@@.@@@@.@.@@@..@.@.@.@@@..@@@@...@@.@@@@@@@.@@.@@.@@@..@@@.@@.@@@.@.@@@@@.@@@.@.@@@@@@@@.@.@@@@@@.@@@@.@@@@.@@@@@..@@.@@.@@@@@
|
||||
.@...@@..@@@@@@@@@@@.@@@.@@.@...@..@@.@.@.@.@.@@@@.@...@.@.@.@.@@@@@@@....@@@@.@@@.@@@..@@@@@..@@@@@..@@.@@..@..@@@@@.@..@@....@@@@@@.@.@@
|
||||
@@.@@@@@@@...@@.@..@.@@.@@.@.@@@@@@.@.@@...@.@@@.@@@@.@.@.@.@@..@.@@@@@@..@..@@.@.@@@@.@@.@...@@.@.@@@@@..@.@....@@@@.@@@@@.@@@@..@..@@@@@
|
||||
.@@@@.@@.@.@...@@@@@@@@@@..@...@@@.@@@.@.@..@@@.@@@@@@..@@@..@.@..@@@@@.@.@@@@@@@@..@@@.@.@@@...@@@.@..@@@@.@@@@@@@@@@@...@@@@@@.@@@..@@..
|
||||
@...@@@@.@.@@@@@@.@@.@@@..@.@@@.@@@@@@@..@@@@@@@.@.@.@.@.@@@@.@@.@..@.@@...@@@@@.@..@@@@.@.@@...@@@..@.@..@@@@.@@@@..@@..@@@@@..@@@@.@@@@@
|
||||
.@.@@.@@.@@@.@.@@@@@@.@@@@.@@.@@..@@@@..@@@@.@.@@@@@@@..@@.@@...@@...@@@..@@..@@...@@@@@@@.@.@@@@@.@...@@.@@@@@...@.@.@.@@.@@@@@@@@..@@.@@
|
||||
.@@...@@@@@.@.@@@@@@@.@...@.@@@.@..@@@.@.@.@@.@@@..@.@@.......@@@@@.@@.@@@.@@....@@@@@@..@@@@.@@.@@.@@.@@.@.@@@...@@.@@@@@@..@..@@@@..@@.@
|
||||
..@@@..@.@@...@@@@..@.@@@..@@.@.@.@@.@.@..@@...@@...@@@.@@....@@@@@.@@..@@@@..@.@@@@@@.@@.@@..@.@@@@@@@.@@...@..@.@@@.@@@@@@@@@@@@.@.@...@
|
||||
@@@.@@@.@@..@@@..@@@.@@.@....@@...@.@@@@@.@...@@....@.@.@@@@@.@@@..@@..@.@@@@@@..@.@....@@.@@@.@@@@@..@@.@.@.@@...@@@...@@@.@@..@@.@.@.@@.
|
||||
..@@@@@@.@.@.@@.@@@.@@@@@@@...@..@.@..@@.@...@@.@@@@@@..@@@...@.@@@@@@.@.@@@@@..@@@.@@@@...@.@..@.@.@@.@.@@.@@@@.@.@..@.@@@@@@@@..@@.@..@@
|
||||
@.@@..@@@@@@@@@.@@@@@.@@@.@@@...@..@@@@@@.@@@@..@@..@@@.@@@@@@@@@.@..@@@..@.@@...@...@@@.@@.@.....@.@@@.@@@@@@.@.....@@.@@@@.@@@...@@@..@@
|
||||
@@@@@@.@@@.@@@@@@@@@@.@.@@.@...@@...@@...@@@@.@.@@@@@@..@@@..@@.@@.@@.@.@@@@.@@.@@@..@@@@.@@@@@@.@@.@@@..@@@.@.@..@.@@@@@...@@@@..@@...@.@
|
||||
@@@@@@.@@@@..@@.@.@..@.@.@@.@.@@@.@@@@@@..@@@...@@.@....@..@..@..@@@.@@..@@@@@@@.@.@@@@@@...@@@@.@@@@....@@@@@@..@.@@..@@@....@@@@@@.@@@.@
|
||||
@..@@@@@@@@@.@.@@@...@@@@@@@@@...@.@@@.@@.@..@@.....@..@.@@@@@@.@.@...@@.@..@@@@.@.@@@@.@@@@@@@@.@@.@@@@@@...@@.@@@@@@@.@@@@@@@@.....@.@@.
|
||||
@.@..@@@.@@@@@@@.@..@.@@@@@.@..@...@.@.@.@@@@.@.@.@.@.....@@.@@.@..@@@@.@..@@@@@..@.@@@@.@@@...@....@@@.@@@@@@.@@...@@.@.@@.@..@@@....@.@@
|
||||
.@.@@....@.@@@@@@@@@@..@@@..@@@@@.@.@@@@@@@@.@.@@@..@@@@@@@.@.@..@@@.@@@@@@@@@@@@@...@.@@@..@.@..@@@.@@.@@@@.@.@@@@...@@..@@@@@@@@@@@@.@@@
|
||||
@@@..@@@@@..@@@.@@@@@.@...@...@..@@@@@@@..@@..@@@.@@...@@.@@@.@@@...@.@@@@@@.@@@@@..@@.@@.@.@..@@.@..@@@.@.@@@@@@@..@@.@.........@.@@@....
|
||||
@@@@@.@@.@@@.@@@@..@@......@@@@@@@@@..@@@@@..@@@@...@.@@@@...@.@@@@@..@@@@@@@.@@.@...@.@@...@@...@@.@@@@@..@@@@...@...@..@.@..@@@@@..@..@@
|
||||
.....@.@@@@@..@@@.@@@@@.@.@@..@@...@@@@@@....@@@.@@..@@@@@.@..@@@@@@@.@@..@@@@@@.@.@.@.@@@.@@..@@@.@@@.@@@@@@@.@.@@@@@@@@@@.@.@..@@@@@@.@.
|
||||
@@...@.@@...@@@.@.@@..@.....@@@..@@@@@@@..@@.@@.@@.@@@@@@@@.@@@....@@@@.@@@...@@@.@@@@@@@.@@.@@.@@.@@..@@@@.@..@.@.@.....@@@.@.@@@@@.@@@@.
|
||||
@@@@@@@..@@.@.@@@@.@@@@@@@..@..@@@@..@@@@.@@@@..@@@@.@@@@@@@@@.@@..@@@@@@@@@@@@.@.@@.....@@@.@..@.@@@@....@@@..@..@.@..@..@.@@@.@.@.@.@@@.
|
||||
@@@@@@@@@..@@@.@@@.@.@@@...@@@@.@@@.@@@@.@......@.@...@@.@..@..@.@.@@@@@@@@@@.@..@.@..@@.@@@...@.@@@@@@.@.@@..@..@.@@.@...@@.@@@@.@@.@@@.@
|
||||
@.@@...@.@@@@@.@.@.@@.@@@..@@@@.@@@@@....@.@..@.....@.@@@@@@.@@@@.@@@..@@.@.....@@.@@@@@@.@@@@@.@..@...@.@@..@@..@@@.@@@@.@@@...@.@@@@@@@.
|
||||
..@...@@.@@@@@@@.@@.@@@@.@@.@...@@@@.@@@@.@@@..@.@.@@@@..@@@@@.@@@@@.@@@@@@@.@@@.@@..@@..@@.@@@@..@..@@@@@@.@@@@@@@.@@@@.@.@@.@.@@.@@..@@@
|
||||
..@@@..@.@@@@.@@@@@@..@.@.@@@.@@..@@@@@@@@@@@@.@@.@@@@.@@@.@@@@@@@@.@@@@.@.@@@@@@.@@@@@..@@@.@@@@@@@...@@@@@....@..@...@.@@@@@@@@@@@@@.@@@
|
||||
@@@.@@@.@@.@@@.@@@.@@@..@@@.@@.@@..@.@@.@@@@...@@@@@@@@..@@.@..@@@@.@@@...@@@@@@@@@...@..@@@@@@@@@.@@@.@.@..@.@@.@.@@@@@@@@@.@@..@.@@.@@.@
|
||||
@..@.@@.@@.@..@.@@@@@@@@.@@@@...@..@.@@..@.@..@@@@@@@..@@@.@..@.@@@@@..@@.@@@.@.@@@@@..@@@.....@.@..@@.@.@@@@@@@@.@@@@@@@@..@.@...@@@@@@@@
|
||||
@@@@@@.@.@.@@@@.@@.@@@@@@@.@@@@@.@@@.@.@..@@@@..@@@@@.@@@@@@.@@@.@.@.@.@@.@@@@.@.@@.@..@.@@.@@.@@@@@@@@@.@@@@@@@.@.@.@.@@.@@@.@.@@......@@
|
||||
.@@@@.@@@@.@@.@..@@@@.@@@@@@@@@@.@@@@@..@@@@.@..@@..@@@@@@@@@.@....@@....@@@@.@.@.....@@@.@@..@.@@..@@.@@.@.@@@@...@@@..@.@@.@@@@@@@.@@.@@
|
||||
..@@@@..@..@@.@@@@.@.@@@@.@@@@@.@@@@.@.@.@@.@@@.@@@@@@..@@.@@@@@@@@@@@.@@.@@..@@..@.@@@@.@@@@@...@@@@@@@@...@.@..@@@@..@@@@.@.@.@.@.@@@@@@
|
||||
@@@..@@.@...@.@.@.@@@@@@@@@.@@.@@@..@..@@@@@@@@.@@@.@@@@@@@@@@.....@.@@.@@@.@@.@@..@@@@@@@@@.@@@@@@@@@@@@@.@@.@..@@@@@@..@.@@.@@@@@..@.@@.
|
||||
@.@@@@@@@@@@@...@...@@@@@.@.@@.@@....@.@.@..@.@.@@.@@.@@...@@.@@.@@.@.@..@.@@...@@.@.@@@.@@@@@@..@@.@@.@@@..@@@.@@@.@@@@@@@..@@.@.@@@@.@@.
|
||||
@.@@@@.@.@@@@..@@@@@@.@.@.@@.@@@@.@@.@.@@..@@.@.@@@@@.@@@@@@@.@@@@@.@@@.@@@@@@@@@@..@.@@...@.@.@.@@@.@...@@@@....@.@@..@@@.@.@.@@@@....@@.
|
||||
..@@@@@@.@@@@@.@.@@@.@@@@@@@@....@....@@@.@@@@@...@.@.@@..@..@@.@@@@@..@@@@..@.@@@..@..@.@@@@@@@...@@@@.@@@.@@@@@@.@@@.@@..@@.@@@@.@.@@@@@
|
||||
.@..@.@@.@@....@@@...@@@@@@@@.@@@.@..@@@@...@.@.@@.@.@@@@@.@@@@@.@@..@.....@@@@..@@..@@..@@..@..@.@@...@@@.@@@@@.@@@.@@.@.@.@.@..@@@@@@.@@
|
||||
.@@.@.@@@.@@.@@@..@@@..@@@@@..@@..@..@..@@.@@.@@.@.@@...@@@...@@.@@@@@.@@@@.@@@..@@.@@..@@@@@@@@.@@@@..@@@@..@@.@@@@@@@@@@.@.@..@@..@@@@.@
|
||||
.@@.@@@..@@...@@@.@...@@@.@@.@@@@.@@@.@@@...@.@@@@@.@@.@.@@@@@..@@@.@@@.@.@@@.@@@@@.@@.@@@@...@@@.@@@@@..@.@@@.@@@@@@@@.@.@@@.@@.@@@@..@@.
|
||||
@@@@@@@@.@@@..@.@@@@..@.@@..@@.@...@..@@..@@@@@.@@@@@.@..@@...@.@@.@@@@@.@.@@@@@.@@@@.@@@.@.@.@@@@@@@.@@@.@@.@.@@.@@.@@@@..@..@.@@@@@@...@
|
||||
@..@..@@@...@@@@@.@@.@@@@@.@.@@@@@.@@..@..@..@@@@@@@.@@.@.@@.@@@..@@@@@@@.@@@@.@.@@..@@@.@@@@@@@@@@@@@@@@@@@@.@@..@@.@@@@@.@@@.@@@..@..@@@
|
||||
@....@@@@@@@@@@.@@@@@@@..@@@@..@@@@@@@@...@..@@@@@@.@@..@@.@@@@@@...@@.@@@.@.@@@@@.@...@..@@..@@@.@.@..@@@@@@@@@@..@.@@@@@@@@..@@@...@.@@.
|
||||
.@@@@.@.@.@@@@@.@@@@.@@.@.@@@@@@..@@.@@@.@.@.@@@@@...@@@@@.@@.@@@@@@.@@@@@.@@@@@@@@@@@@.....@....@@@..@@.@.@@..@@@..@.@@@.@@@@@@@.@@..@@@.
|
||||
.@@..@.@@@@.@.@@@@@....@@@.@@....@@@.@.@.@@......@@@@@@@@.@@@@@.@@@@@@.@@.@.@@@.@@@@@@.@..@@@@@@..@@.@@@.@@.@@@.@.@.@@@@.@@@@@.@.@@@..@@..
|
||||
.@@.@.@.@@..@@@@...@@..@.@....@.@@..@@@.@@.@..@@@..@@@@.@@..@.@@@@@@.@@..@@.@@..@@@.@@@.@@..@@@.@@.@..@@@@@@.@..@.@@@@..@..@..@..@....@.@@
|
||||
.@.@@@@.@..@@.@.@@@@.@....@..@@@@@.@@.@.@@@.@@@@@@@.@@@.@@@@@@@..@@@.@.@@....@@@@@@@@@@@@@@@.@@@.@@@@@@.@@..@..@@@.@.@..@@@@.@@.@@....@...
|
||||
.@....@..@@.@@@.@@@@@.@@..@@.@@...@@...@.@.@.@@@@@@@@...@@@@@@@@@@.@@@@@..@..@.@..@..@@@@@@.@@@@@@@@@@@.@@@@@@@.@..@.@@@@@@@@.@@@@@@@@@@..
|
||||
.@.@@@@.@.@.@.@.@.@@.....@.@..@@.@.@@@..@@.@@@@.@@@@.@@@@@@@@.@@@@.....@@@.@@@.@@@@@.@.@@@@@.@..@@@@@.@@.@@.@.@@@@.@@@.@@.@@@.@@..@@@@@...
|
||||
@@@.@.@@..@.@...@.@@.@@@@@@@@@@@@.@@@@.@...@.@@@@@@@@@@@@@.@.@@@@@@.@@@@@.@@@@@@.@.@@@@@.@@........@@.@.@@@@@@@@@@@@@@@@@.@@@.@..@@@@@@@@@
|
||||
@.@@@@@@.@@@@.@@@@.@.@@..@@@@.@.@....@@.@..@@@.@@.@@@@.@@@@@@.@...@.@@@@@..@@.@@.@@..@.@@..@@@@@@.@.@.@.@.@@.....@@@.@@@@@@.@@@@@@@@@@.@.@
|
||||
@@@@....@@@@..@.@@@@@@.@@.@@@@@..@@..@@@.@.@@@.@@@@@..@@@...@.@..@@@@@@.@@@..@@@.@@@@@@.@@@..@@@@@@@@@.@@@.@@@@@@.@.@@@.@@..@@@@@@@..@@@@.
|
||||
@@@@.@@@@@..@.@@@.@@@@@@@@@.@@.@@..@.@.@..@@..@@..@.@@.@..@.@@@@.@@..@..@.@@@@@.@@@...@.@..@@@.@.@.@@@@@@@@...@..@@@@@.@@.@@.@@@.@@@.@.@.@
|
||||
...@@.@@@@@..@.@.@@.@@@@@@..@@......@@@@@@.@.@@.@@@.@@.@@@@@.....@@@@.@@@@@..@@@.@@.@......@.@@@.@@....@@.@.@.@@..@.@.@@@@@.@.@@@..@@@@@@@
|
||||
.@@@@.@@@.@@.@@@.@@@@@@.@@@@@@.@@@@@@..@@@.@.@@.@@@.@@@@@@@.@.@.@..@@@@..@@@@@@.....@@@..@@@...@@@@.@@.@.@....@@..@@@@@@.@@@@.@@.@.@..@@@.
|
||||
@@...@...@@@@@@@@.@....@@@.@@@.@@@@@..@@.@@@@@@.@..@@..@.@.@@@@.@@@@.@@...@@.@@.@.@.@@.@@..@@@@.....@@@@@@...@.@@@@@@.@.@@@@@@.@@@@@...@.@
|
||||
...@@.@@@..@@.@..@@.@@@.@@@.@@.@@@.@.@@@.@.@.@@@@...@@.@..@.@@@..@@@.@.@.@@@@..@@@@.@@.@.@@@@@@@@@..@.@..@.@..@@@@@.@..@..@@@@@@.@@.@@@@..
|
||||
@.@.@.@@@..@@@@@.@.....@@@@.@@@.@@@@.@@@@.@@.@.@@..@@@@.@@@.@@..@@.@@@..@@@@.@@@@.@@@.@@@.@@@.@@@@@.@.@@@..@@.@@@@@@..@...@..@@.@@@@..@@..
|
||||
@@@@@@@@@..@..@.@@....@@@@@@@@.@@@.@@@.@.@@.@@@@@@...@@@@@.@.@@@..@......@@@.@@@.@@@.@.@@@@@.@.@@.@@..@@@..@@.@@@.@..@@@..@.@@@@@@@@@...@@
|
||||
...@@@.@@@..@..@@@@.@@@@@@@@@.@...@@@@@.@@@@@@@@.@@@@...@@..@.@.@.@@@.@@.@.@@@@...@@@.@@.@.@.@@.@.@@@.@@@@@@..@@.@@@.@@@..@.@.@@.@@@@.@@@.
|
||||
@@..@@@@@@..@.@....@@.@.@@@...@@@@@....@@@@.@.@..@@@.@@@.@@@...@@@@@..@.@@@@@@.@@@..@@@..@.@@@@@@@@...@@@@.@..@..@@@@.@..@@@@@...@.@.@.@@.
|
||||
@.@@.@..@@@@@@.@@..@@@@@@..@@.@@@@..@@@..@@@@.@.@@@.@@.@@.....@@@@.@..@@.@@@@@@@@.@.....@@.@.@.@.@@@@@..@@...@@@..@..@@@@@@@@.@@@..@...@..
|
||||
.@@.@@@@@.@@@.@@.@.@.@@....@@.@@...@@.@..@.@@@@@@@@@@@@.@@@@@.@@.@@@.@@..@@@@..@@@.@@.@@..@...@.@@@@@...@@@@.@@.@@@@.@@.@@.@@@@@@@@@@.@@.@
|
||||
@@@@.@@@.@@.@@.@@@@@.@@@.@@@@..@.@@@.@@@.@..@..@@@@@@@@@@@@...@@@@.@@@@@@@@....@..@.@@..@@@@@@...@@@...@@@@@@@.@..@@@@..@@..@@@@..@@@.@@@@
|
||||
@@@..@@.@@..@@@@@@@@@@@@@@.@.@@@.@@@@....@@@.@@@.@.@....@@@@@@.@@.@@@.@@@@.@@@.@..@..@@@..@@..@@@@.@@....@@...@..@@@@@@@@..@@..@@@..@.@@@@
|
||||
.@.@@.@@@@@..@@.@@@@@@..@@.@@@@@@.@@@@@@@.@.@@@.@@.@@@@@.@..@@@...@.@..@..@@@@@@@.@@@.@@@.@@@@.@@@@@@@@@@@.@@@@@..@@@@.@@.@.@@@........@@@
|
||||
.@@.@@..@@@@@@@@.@@@@.@@@@@@..@.@.@@@..@.@@.@.@.@@@@@@.@@@@@..@@..@@.@@@@@..@.@@@@@@.@@@@.@..@.@.@.@@@.@@@@.@@.@@.@.@@@@@..@.@.@@@@.@@.@..
|
||||
.@@@..@@@...@...@@.@..@.@@@..@@..@@.@@..@@..@@@.@@..@....@.@@@.@@@.@@.@@..@@@@@@.@@@@@@@.@..@@@@@@.@.@.@@@.@@@@..@@.@@..@@@@@@@@.@@@@@.@@@
|
||||
...@@@@@@@@.@@@@.@@@.@.@.@@@.@..@.@..@@@.@..@.@@@@@@..@.@@.@@......@@@.@.@@@@@@@.@@@@...@@.@@..@...@@@.@@.@@@.@@..@.@.@@@@@@@.@@@@@.@@.@..
|
||||
@@..@@@@@@@.@@@.@@@@@@@.@@@@@@@@@.@@.@@@....@.@@@@@.@@@@.@@.@..@@@@@@@@@@.@@@.@@.@.@@.@@@@@..@@..@@@@@@.@@@@.@@@..@....@@@@@@@@@..@@@@@.@@
|
||||
@@...@@.@.@@.@@@@@.@@.....@@@@@@.@.@@@@@@..@@@@@.@.@@@@@...@..@@.@@@@@@.@.@.@@@@@@@.@@@..@@...@@@@..@.@.@@@..@@@@@@...@@@..@..@@.@.@@..@@.
|
||||
..@@@@@@@@@@@@.@@@..@@@..@@..@@@....@@.@@..@@.@@..@@@.@..@.@@@@@.@@.@.@.@@@.....@.@@.@@@..@@..@@.@@..@@@.@@@.@@.@.@.@@.@@...@.@@..@@..@@@@
|
||||
@..@@@@@@@@.@@..@.@..@@.@@@@@.@.@@@@@@.@.@.@.@..@.@....@..@@@.@.@@@@@@@..@@@@@@@@@.@@@@@.@@@@@@.@@@@.@@@@@@@.@@@@.@@.@@@.@.@@.@...@@...@@@
|
||||
@@@.....@.@..@@@@....@@.@..@@@@@@@...@.@.@@@@@..@..@.@.@@@.@.@@@.@...@..@@@@@.@.@@...@..@@@@.@@.@@@.@@@@@..@@@@@...@@@@.@.@@@@.@..@....@@@
|
||||
.@..@.@...@@@@@.@@@..@@@@@..@@.@@@@@.@@.@.@@@@@.@.@@...@.@..@.@.@@.@@.@@....@.@..@@@@.@@@.@.@@..@@@@@@..@@.@..@@@@@@...@@@@.@@@@@..@@.@@@.
|
||||
..@.@.@.@@.@@@@@..@@.@@..@.@@.@@@.@@@@@@.@@@@@.@@..@.@.@.@@..@.@.......@@@@@@@@.@@@@@....@..@@@.@@@..@.@...@@@@.@@@.@@@.@@@@@@..@..@@@.@@.
|
||||
@@@.....@@..@@@.@.@@@@@@@.@..@.@@.@...@@@.@..@@@@.@...@.@@.@@.@@..@@@....@@@.@..@@.@...@@@@@@@.@@@@@@@@.@.@@..@@@@@@@@@...@@@.@@@.@@.@@.@.
|
||||
@@.@@@@.@..@.@@...@.@@@@.@@@.@..@.@.@@@@@@.@..@@@@@@.@.@@@@@@@@@@@@@@.@.@@.@@@@.@.@@@@@@.@...@.@@.@@@.@@..@@@.@@@@@..@.@@..@@..@@@@@@.@..@
|
||||
@@.@....@.@.....@.@@@@@@@@@.@.@..@@.@.@@@@@@.@.@..@@@.@....@..@@@.@@@.@.@.@..@@@@@@@@@@@@..@@@.@@@@..@@@.@@.@@@.@@@.@@@@.@@..@@@@.@@@@.@@.
|
||||
.@@@..@@..@@.@..@.@.@.@@@@..@.@.@@@@@@.@@@@.@.@.@@@@.@@@@...@@..@@@@@.@@@.@.@.@@@@.@@.@.@@@@@.@.@.@..@@@....@@@@.......@@@@@@.@@@@@@@@@.@@
|
||||
.@.@@.@.@.@.@@@@@@...@@..@@..@.@@@@..@.@@..@@@@@@@@.@@.@@@@.@..@@@@.@.@@@.@.@@@.@@.@.@@@@.@.@..@@@@..@@.@@@...@@...@@@@@@@@@@@.@@@@@.@.@@.
|
||||
@.@@.@@.@.@@@.@@@@@....@@..@@@@@@@@.@@.@@@@@.@.@@.@.@@...@@.@@@@@.@@.@@.@@.@@@@@@@@@..@@...@@..@@@..@@@@.@@@@..@..@@@@@@.@.@@@..@@@@.@@@@@
|
||||
@.@@@@@.@@@@....@@@@@@@@@..@@@..@@@@.@@@@@@@@@.@.@@@..@@@.@.@@.@@.@@.@@@...@@@@@.@@.@@@@@.@.@@@@...@..@.@@..@@@@@..@@@@@..@@@@@...@@.@...@
|
||||
@@@.@@.@@@@@@.@@.@@.@@@.@.@@@.@....@@@..@.@@@.@.@@.@.@.@@.@@@.@@@.@@@@@@.@@@@@@@@@@@@@@@.@@@@@@@@@.@.@@@.@.@@@.@@@@@@@..@@.@.@@.@....@.@@@
|
||||
@.@.@@@@@.....@@@@@.@@@@@..@@@..@.@@@@@...@...@@@.@@@.@@@.@@.@@.@@@..@@.@@@@.@.@@..@@@.@@.@.@.@@.@.@@@.@@@.@.@...@.@@@@@.@.@@@@@.@@.@@@.@.
|
||||
@.@.@@@@@@@@@.@@@@....@@.@@@..@@@.@@@.@.@@.@@@..@.@.@..@@@..@@.@@@@@@@@@..@.@.@@@@@.@.@@@@@..@@@.@@@@@.@@@.@@.@.@@@@@@@@@@..@..@@@...@@..@
|
||||
@@@@@@.@.@@.@@@.@@..@..@@@@.@@@@.@.@@@@@@...@@@.@.@@@.@@..@...@.@@@@...@@..@.@@@@@@@@.@.@@@@@.@@@..@@@@@...@@@@@@..@@@.@@@@@@@@..@@@@@@@.@
|
||||
@.@@..@@@@@@@@@@.@..@@..@.@.@.@@@@.@@..@..@.@@.@@@@@@.....@..@@@.@@@.@@@@.@.@.@@@@.@.@.@@@.@..@.@@@@..@@@.@@.@.@@.@@@....@@@.@.@@.@@@@.@@@
|
||||
@.@.@.@@@@@.@..@.@@.@@@@@.@@@@@@@@@.@.@.@.@@@.@....@.@@@@@.@@.@@@@.@@@@.@.@@@@..@.@@@@....@@@@@..@.@@@@@@@.@@@@..@@@@...@@...@@@@@..@@@...
|
||||
@@..@...@@..@.@@.@@@@@@@@@.@@@.@@.@@@@@@.@.@@@@.@.@.@@@@@...@@.@@.@.@..@@.@...@.@@@@.@.@@@@@..@@@.@@@@@@@.@.@@@@@@@@.@@@@.@@@...@.@.@@@.@.
|
||||
@@@@@@@@@..@.@..@@@.@.@@@@.@.@@@@@..@..@@@.@@..@@@.@.@@@.@.@@@@@.@@.@@@.@@@@@.@@.@...@@@@..@.@@.@..@@...@.@@@.@@..@@@.@@@.@.@.@@@...@@@@@.
|
||||
..@.@..@@@@@@..@@@.@@@@@.@@@@.@@.@@..@@@.@.@@.@@.....@@.@..@@..@.@@@@@.@@...@@@@@@@.@@...@@@@.@@@@..@@.@.@@@@@..@@@...@..@@@@@.@.@.@@@@@@.
|
||||
.@.@@.@@.@@@.@@@..@@@@@.@@@@@@@@@.@@@@.@@@.@@.@@.@.@..@.@@@@.@@.@@@....@.@@@..@@@...@@.@@.@@....@@@.@@@.@@@..@@@@@@@..@@@..@@...@@...@.@@.
|
||||
.@.@@@..@..@@.@@.@.@.@@@@@@@@@.@..@.@@.@.@@@@.@@@.@..@.@@@@.@.@@.@@@.@@.@.@@@.@@@..@.@@@@@@@@.@@.@.@@@@@@...@@.@@@...@.@@.@@..@@@..@..@@.@
|
||||
@@@@@.@@@@.@@@@@@@..@@@@@@@@.@.@.@@@@@@@.@@....@@.@@@@@@@@@@@@@@@@@@@@@@@@.@@@.@@@@..@.@..@.@.@@@@@@@@.@.@@@.@@@@@...@@.@.@@...@@@.@.@@..@
|
||||
@@@.@@@@.@....@@@@.@@@@.@@@@@.@.@.@@@@.@.@..@@@.@...@.@.@@@...@@@@@.@@@@@.@.@@@@.@.@@@.@@.@@.@@@.@..@@@@.@@@.@@@@@...@@@..@@@@.@...@...@@@
|
||||
.@.@...@@@.@@..@.@@.@@@..@@.@@.@..@@..@@@@@@..@.@@@.@@@@.@@@@.@.@@@@@@..@@.@@@..@...@@@@@.@@@@@@@@.@@@.@.@@@.@@@@@.@..@.@@..@@@@@@@.@@@@@.
|
||||
....@.@...@@@@@@..@@@@@@@@@@@.@.@@@@@.@@@@@@@@.@...@@@.@.@@@@@.@@@@@@@.@.@.@@.@@@@..@...@..@@@.@@@@.@@...@@@@@@@@.@..@.@@@@@@..@@@.@@.@.@@
|
||||
@.@@@..@@.@@@.@@@@@....@@@@..@@@@.@.@...@@.@..@@@..@@...@@@..@@.@@.....@@@@.@@@@@@@@@@@@@@.@.@.@@@@@..@@@@@@..@@@@@@@@.@.@.@.@@..@.@.@.@.@
|
||||
@@@..@@@....@@.@@@@.@@....@@@@..@.@.@@.@@..@@@.@@@.@@@@@@@@..@@.@@@@@@...@@@..@.@@@.@@@@.@@@..@@@@@@@@@@@@@@.@@@@@@.@@@..@..@@...@@@@@@@..
|
||||
@@@...@..@.@..@@@@..@.@@@@@..@@@@.@....@@..@.@.@.@@@@@@@@.@@@@@.@.@...@@@.@@@..@@@@.@@@.@@@@.@.@@.@...@@@@@..@@.@@@...@..@@@@..@@@.@@@@@@@
|
||||
.@@@@@@@.@..@.@@..@@@@@@@.@@...@@@@@@.@..@@..@.@@@@@@..@.@@@@@.@@@@.@.@@.@@@...@@@..@@..@@@.@@@@@@@..@@@..@....@@@.@@@.@.@@@@@@@@@@.@@@@..
|
||||
.@@@@@@@@@@..@@.@@@.@@@.@@.@@@@.@..@.@@@@.@@@@@@@@@@@@@@.@@..@@.@@@@@@@@@@@..@.@@.@@.@@@@.@@..@@@@@@@@.@@..@@@.@.@@@...@@@@@.@@@.@..@@@.@@
|
||||
.@..@@@.@@@@@@@@@@.@@@@@@@@@@@@@@@@@.@..@@@@.@.@.@.@@.@@.@@..@.@@@@@@@@.@@@...@@@.@@@@@@@.@.@..@@@@@@@..@@@..@@@.@@@@@.@@@@.@..@.@@@@.@.@@
|
||||
.@@@@.@.@@@.@@@..@@...@.@@..@@.@@@@@@@@.@@@@.@@@@.@@.@@..@@...@@@@.@@@.@@.@.@@.@@.@.@.@@@.@@@...@@@...@@@@@@@@.@.@@..@.@@@@@..@@@..@.@@.@.
|
||||
..@.@@....@@@.@@@@@...@.@@@@@@@....@@.@@@@@@@@.@@@@.@@...@.@@@@...@@@@.@@..@@@@@@.@@@.@@@@@@.@.@@@@.@....@@@@.....@@@..@@@.@@..@.@@@.@@.@@
|
||||
..@@@.@@@.@.@@@@@@@@...@@@@@@@@.@@@.@@@@@.@@@.@@@@..@@@..@.@@@@@@.@.@.@@@@@@@@@...@@@@@@@.@@@@@@...@@@@@@@@@.@@..@.@.@@@@@.@@.@@.@.@@@@@@.
|
||||
@.@.@@..@@.@@.@@.@@@@.@@@.@@@@@.@.@.@@@@@@.@..@@.@.@@@.@....@.@@.@@.@@@@@@@.@@@.@@@.@@@@@@@.@@.@@..@@@@@@@......@..@.@@..@..@..@...@@@.@@@
|
||||
@@@.@....@@@@@@.@@@@@@@@@..@@@@.@@..@.@@.@@.@.@@@.@.@@.@.@....@@...@.@.@@@@@@@@@.@.@@.@.@@..@@.@.@@@@@@@.@@@.@.@.@@@..@@.....@@@@@@@@..@..
|
||||
@.@@.@@.@@@@@@@@.@.@@@@..@@@@@..@@@@..@@@@.@.@@..@@@@@@.@.@@...@@@..@.@@@.@.@@..@.@.@@@..@@@.@.@..@@@.@@@.@@.@@.@...@.@....@@.@..@@@@@.@.@
|
||||
@@.@@@@@@@.@@@..@@@@@.@@.@.@@@..@@@@@.@..@.@@@.@.@@@@@@@@...@@.@@...@@.@.@@.@@.@@@@@@@.....@.@.@..@@.@@.@.@..@@...@@.@..@.@@@@.@@@@.@@@.@@
|
||||
..@@@.@@@@@.@..@@@@@@@.@@@@@@@..@@@...@@@@@@..@.@....@@@@.@@@@.@.@@@@@..@@@@@....@@@@@@.@.@.@@@@..@@@@@.@@@@@.@@....@@@@..@@.@@...@@@@@@@.
|
||||
@@..@@@@@.@.@@@@@@@@@@@@@@.@@@.@.@@@.@.@@.@.@@@@@@.@.@@@..@.@@.@..@@@.@..@@..@.@@@.@@@@.@@@@.@@@.@@.@@.@.@@@@.@@.@@@..@@@@@..@@@@@@@...@@@
|
||||
@.@@....@.@@@@@@@@@@@@@.@@.@@@@@.@@@@..@@@@@.@.@@@@..@.@.@@@.@@.@..@@.@@.@.@...@@@@..@..@...@@@..@@.@@@.@@.@.@.@.@..@..@@@..@..@@..@@@.@.@
|
||||
@.@.@.@@.@.@.@@..@@@..@@@@@@..@@@.@....@..@.@@@@@.@@...@@@..@@.@@.@@..@..@@@@@@.@@..@@@@@@@.@.@@@.@..@.@.@@...@@...@.@..@.@@@.@..@.@...@@@
|
||||
@@@....@@@..@.@.@@@.@@.@@@@@@..@@.@.@@@@@..@@.@@@@..@@.@...@@.@@@@@@@...@.@@@@@.@.@...@@@@@@@.@@..@..@@@..@.@@.@@@.@.@@..@@@.@..@@@.@@..@@
|
||||
@@@@@.@.@@@@.@...@@.@@@.@.@@.@.@@@.@.@@.@@@@@@@.@@@@@.@@@@..@@@@@@.@@@@.@.@@@.@@.@@...@@@...@..@@@@@@@..@@.@@.@@.@@@.@.@..@@@@@@....@.@.@.
|
||||
3
src/day04/src/lib.rs
Normal file
3
src/day04/src/lib.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod part04a;
|
||||
pub mod part04b;
|
||||
|
||||
55
src/day04/src/part04a.rs
Normal file
55
src/day04/src/part04a.rs
Normal file
@@ -0,0 +1,55 @@
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
pub fn solve() -> u64 {
|
||||
let mut solution: u64 = 0;
|
||||
|
||||
let mut file: File = File::open("src/day04/input04.txt").unwrap();
|
||||
let mut file_content: String = String::new();
|
||||
file.read_to_string(&mut file_content)
|
||||
.expect("Can't read file");
|
||||
|
||||
let mut rows: Vec<Vec<u8>> = Vec::with_capacity(file_content.len() + 2);
|
||||
rows.push(vec![0u8; file_content.len()]);
|
||||
rows.append(
|
||||
&mut file_content
|
||||
.lines()
|
||||
.map(|line| {
|
||||
let mut col: Vec<u8> = Vec::with_capacity(line.len() + 2);
|
||||
col.push(0u8);
|
||||
col.append(
|
||||
&mut line
|
||||
.chars()
|
||||
.map(|c| match c {
|
||||
'@' => 1u8,
|
||||
_ => 0u8,
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
col.push(0u8);
|
||||
col
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
rows.push(vec![0u8; file_content.len()]);
|
||||
|
||||
rows.windows(3).for_each(|rows| {
|
||||
rows[0]
|
||||
.iter()
|
||||
.zip(rows[1].iter())
|
||||
.zip(rows[2].iter())
|
||||
.map(|((a, b), c)| (*a, *b, *c))
|
||||
.collect::<Vec<(u8, u8, u8)>>()
|
||||
.windows(3)
|
||||
.for_each(|cols| {
|
||||
if cols[1].1 != 1u8 {
|
||||
return;
|
||||
}
|
||||
if cols.iter().map(|(a, b, c)| *a + *b + *c).sum::<u8>() - 1 < 4 {
|
||||
solution += 1;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
solution
|
||||
}
|
||||
16
src/day04/src/part04b.rs
Normal file
16
src/day04/src/part04b.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
pub fn solve() -> u64 {
|
||||
let mut solution: u64 = 0;
|
||||
|
||||
let mut file: File = File::open("src/day04/input04.txt").unwrap();
|
||||
let mut file_content: String = String::new();
|
||||
file.read_to_string(&mut file_content)
|
||||
.expect("Can't read file");
|
||||
|
||||
solution
|
||||
}
|
||||
|
||||
|
||||
|
||||
29
src/day04/story04a.txt
Normal file
29
src/day04/story04a.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
--- Day 3: Lobby ---
|
||||
|
||||
You descend a short staircase, enter the surprisingly vast lobby, and are quickly cleared by the security checkpoint. When you get to the main elevators, however, you discover that each one has a red light above it: they're all offline.
|
||||
|
||||
"Sorry about that," an Elf apologizes as she tinkers with a nearby control panel. "Some kind of electrical surge seems to have fried them. I'll try to get them online soon."
|
||||
|
||||
You explain your need to get further underground. "Well, you could at least take the escalator down to the printing department, not that you'd get much further than that without the elevators working. That is, you could if the escalator weren't also offline."
|
||||
|
||||
"But, don't worry! It's not fried; it just needs power. Maybe you can get it running while I keep working on the elevators."
|
||||
|
||||
There are batteries nearby that can supply emergency power to the escalator for just such an occasion. The batteries are each labeled with their joltage rating, a value from 1 to 9. You make a note of their joltage ratings (your puzzle input). For example:
|
||||
|
||||
987654321111111
|
||||
811111111111119
|
||||
234234234234278
|
||||
818181911112111
|
||||
|
||||
The batteries are arranged into banks; each line of digits in your input corresponds to a single bank of batteries. Within each bank, you need to turn on exactly two batteries; the joltage that the bank produces is equal to the number formed by the digits on the batteries you've turned on. For example, if you have a bank like 12345 and you turn on batteries 2 and 4, the bank would produce 24 jolts. (You cannot rearrange batteries.)
|
||||
|
||||
You'll need to find the largest possible joltage each bank can produce. In the above example:
|
||||
|
||||
In 987654321111111, you can make the largest joltage possible, 98, by turning on the first two batteries.
|
||||
In 811111111111119, you can make the largest joltage possible by turning on the batteries labeled 8 and 9, producing 89 jolts.
|
||||
In 234234234234278, you can make 78 by turning on the last two batteries (marked 7 and 8).
|
||||
In 818181911112111, the largest joltage you can produce is 92.
|
||||
|
||||
The total output joltage is the sum of the maximum joltage from each bank, so in this example, the total output joltage is 98 + 89 + 78 + 92 = 357.
|
||||
|
||||
There are many batteries in front of you. Find the maximum joltage possible from each bank; what is the total output joltage?
|
||||
25
src/day04/story04b.txt
Normal file
25
src/day04/story04b.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
--- Part Two ---
|
||||
|
||||
The escalator doesn't move. The Elf explains that it probably needs more joltage to overcome the static friction of the system and hits the big red "joltage limit safety override" button. You lose count of the number of times she needs to confirm "yes, I'm sure" and decorate the lobby a bit while you wait.
|
||||
|
||||
Now, you need to make the largest joltage by turning on exactly twelve batteries within each bank.
|
||||
|
||||
The joltage output for the bank is still the number formed by the digits of the batteries you've turned on; the only difference is that now there will be 12 digits in each bank's joltage output instead of two.
|
||||
|
||||
Consider again the example from before:
|
||||
|
||||
987654321111111
|
||||
811111111111119
|
||||
234234234234278
|
||||
818181911112111
|
||||
|
||||
Now, the joltages are much larger:
|
||||
|
||||
In 987654321111111, the largest joltage can be found by turning on everything except some 1s at the end to produce 987654321111.
|
||||
In the digit sequence 811111111111119, the largest joltage can be found by turning on everything except some 1s, producing 811111111119.
|
||||
In 234234234234278, the largest joltage can be found by turning on everything except a 2 battery, a 3 battery, and another 2 battery near the start to produce 434234234278.
|
||||
In 818181911112111, the joltage 888911112111 is produced by turning on everything except some 1s near the front.
|
||||
|
||||
The total output joltage is now much larger: 987654321111 + 811111111119 + 434234234278 + 888911112111 = 3121910778619.
|
||||
|
||||
What is the new total output joltage?
|
||||
42
src/main.rs
42
src/main.rs
@@ -1,44 +1,60 @@
|
||||
use std::fmt::format;
|
||||
use std::time::Instant;
|
||||
use day01::{part01a, part01b};
|
||||
use day02::{part02a, part02b};
|
||||
use day03::{part03a, part03b};
|
||||
use day04::{part04a, part04b};
|
||||
use std::fmt::format;
|
||||
use std::time::Instant;
|
||||
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::io::Result;
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
let mut file = OpenOptions::new()
|
||||
.write(true) // Open the file for writing
|
||||
.create(true) // Create the file if it doesn't exist
|
||||
.truncate(true) // Clear the file if it already exists
|
||||
.open("README.md").expect("Cannot open or create file");
|
||||
.write(true) // Open the file for writing
|
||||
.create(true) // Create the file if it doesn't exist
|
||||
.truncate(true) // Clear the file if it already exists
|
||||
.open("README.md")
|
||||
.expect("Cannot open or create file");
|
||||
|
||||
file.write_all(b"# Advent of Code 2025\n```bash\n").expect("Cannot write to file");
|
||||
file.write_all(b"# Advent of Code 2025\n```bash\n")
|
||||
.expect("Cannot write to file");
|
||||
|
||||
let exercises: Vec<(&str, fn () -> u64)> = vec![
|
||||
let exercises: Vec<(&str, fn() -> u64)> = vec![
|
||||
("day01:A", part01a::solve),
|
||||
("day01:B", part01b::solve),
|
||||
("day02:A", part02a::solve),
|
||||
("day02:B", part02b::solve),
|
||||
("day03:A", part03a::solve),
|
||||
("day03:B", part03b::solve),
|
||||
("day04:A", part04a::solve),
|
||||
("day04:B", part04b::solve),
|
||||
];
|
||||
|
||||
let start: Instant = Instant::now();
|
||||
exercises.iter().for_each(|(day, func)| {
|
||||
let day_start: Instant = Instant::now();
|
||||
let solution = format!("{:7} => {:15} ({:6}us)\n", day, func(), day_start.elapsed().as_micros());
|
||||
let solution = format!(
|
||||
"{:7} => {:15} ({:6}us)\n",
|
||||
day,
|
||||
func(),
|
||||
day_start.elapsed().as_micros()
|
||||
);
|
||||
print!("{}", solution);
|
||||
file.write(solution.as_bytes()).expect("Cannot write to file");
|
||||
file.write(solution.as_bytes())
|
||||
.expect("Cannot write to file");
|
||||
});
|
||||
|
||||
let banner = " ----------\n";
|
||||
let end_time = format!(" {:7}us\n", start.elapsed().as_micros());
|
||||
let end_time = format!(
|
||||
" {:7}us\n",
|
||||
start.elapsed().as_micros()
|
||||
);
|
||||
print!("{}", banner);
|
||||
file.write(banner.as_bytes()).expect("Cannot write to file");
|
||||
println!("{}", end_time);
|
||||
file.write(end_time.as_bytes()).expect("Cannot write to file");
|
||||
file.write(end_time.as_bytes())
|
||||
.expect("Cannot write to file");
|
||||
file.write(b"```").expect("Cannot write to file");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user