├── .gitignore ├── Cargo.toml ├── AdventOfCode2025.code-workspace ├── src └── bin │ └── 1.rs └── Cargo.lock /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aoc_2025" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | aoc_2024 = { path = "../AdventOfCode2024", version = "0.1.0" } 8 | -------------------------------------------------------------------------------- /AdventOfCode2025.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | }, 6 | { 7 | "path": "../AdventOfCode2024" 8 | } 9 | ], 10 | "settings": {} 11 | } -------------------------------------------------------------------------------- /src/bin/1.rs: -------------------------------------------------------------------------------- 1 | use aoc_2024::*; 2 | use std::error; 3 | 4 | fn p1(input: I) -> usize 5 | where 6 | I: IntoIterator, 7 | S: AsRef, 8 | { 9 | input 10 | .into_iter() 11 | .scan(50, |acc, line| { 12 | let line = line.as_ref(); 13 | let mut d = line[1..].parse::().unwrap(); 14 | if line.starts_with('L') { 15 | d = 100 - d; 16 | } 17 | *acc = (*acc + d) % 100; 18 | Some(*acc) 19 | }) 20 | .filter(|v| *v == 0) 21 | .count() 22 | } 23 | 24 | fn p2(input: &Vec) -> usize { 25 | let iter = input.iter().flat_map(|line| { 26 | let line = line.as_str(); 27 | let d = line[1..].parse::().unwrap(); 28 | let dir = if line.starts_with('L') { "L1" } else { "R1" }; 29 | std::iter::repeat(dir).take(d).map(|s| s.to_string()) 30 | }); 31 | p1(iter) 32 | } 33 | 34 | fn main() -> Result<(), Box> { 35 | let input = read_in()?; 36 | write_out(p1(&input)); 37 | write_out(p2(&input)); 38 | Ok(()) 39 | } 40 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "1.1.4" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "aoc_2024" 16 | version = "0.1.0" 17 | dependencies = [ 18 | "itertools", 19 | "regex", 20 | ] 21 | 22 | [[package]] 23 | name = "aoc_2025" 24 | version = "0.1.0" 25 | dependencies = [ 26 | "aoc_2024", 27 | ] 28 | 29 | [[package]] 30 | name = "either" 31 | version = "1.15.0" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" 34 | 35 | [[package]] 36 | name = "itertools" 37 | version = "0.13.0" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" 40 | dependencies = [ 41 | "either", 42 | ] 43 | 44 | [[package]] 45 | name = "memchr" 46 | version = "2.7.6" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" 49 | 50 | [[package]] 51 | name = "regex" 52 | version = "1.12.2" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" 55 | dependencies = [ 56 | "aho-corasick", 57 | "memchr", 58 | "regex-automata", 59 | "regex-syntax", 60 | ] 61 | 62 | [[package]] 63 | name = "regex-automata" 64 | version = "0.4.13" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" 67 | dependencies = [ 68 | "aho-corasick", 69 | "memchr", 70 | "regex-syntax", 71 | ] 72 | 73 | [[package]] 74 | name = "regex-syntax" 75 | version = "0.8.8" 76 | source = "registry+https://github.com/rust-lang/crates.io-index" 77 | checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" 78 | --------------------------------------------------------------------------------