- commit
- cad83dba4d2f173fc0ec6d9db6a3d16393525a0a
- parent
- 9cb36ef0237c27124ed87577e72271249aacf9d5
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2026-12-02 16:39
2026-12-02
Diffstat
| A | 2026/02/solution.rs | 32 | ++++++++++++++++++++++++++++++++ |
| A | 2026/02/test.txt | 1 | + |
2 files changed, 33 insertions, 0 deletions
diff --git a/2026/02/solution.rs b/2026/02/solution.rs
@@ -0,0 +1,32 @@
-1 1 #[path = "../lib.rs"]
-1 2 mod lib;
-1 3
-1 4 fn main() {
-1 5 let mut dist: i32 = 0;
-1 6 let mut n = 0;
-1 7
-1 8 for line in lib::iter_input() {
-1 9 for c in line.chars() {
-1 10 let target = match c {
-1 11 'r' => 0,
-1 12 'o' => 1,
-1 13 'y' => 2,
-1 14 'g' => 3,
-1 15 'b' => 4,
-1 16 'v' => 5,
-1 17 _ => unreachable!(),
-1 18 };
-1 19
-1 20 n += 1;
-1 21 dist += match (target - dist).rem_euclid(6) {
-1 22 0 => 6,
-1 23 d => d,
-1 24 }
-1 25 }
-1 26 }
-1 27
-1 28 println!("part1: {}", dist);
-1 29
-1 30 // assuming all 6 colors are used
-1 31 println!("part2: {}", n * 6 - 5);
-1 32 }
diff --git a/2026/02/test.txt b/2026/02/test.txt
@@ -0,0 +1 @@ -1 1 obbvb