Implement AoC 2025 #1

Open
leon wants to merge 22 commits from 2025 into main
3 changed files with 1239 additions and 0 deletions
Showing only changes of commit fcf2c58b71 - Show all commits

37
2025/05.rs Normal file
View File

@@ -0,0 +1,37 @@
---cargo
---
static CONTENT: &'static str = include_str!("./inputs/05_1.txt");
fn main() {
let mut ranges: Vec<_> = CONTENT.lines().map(|l| l.trim()).take_while(|l| !l.is_empty()).map(|r| {
let (start, end) = r.split_once('-').unwrap();
let start = start.parse::<usize>().unwrap();
let end = end.parse::<usize>().unwrap();
start..=end
}).collect();
println!("Ranges: {:?}", ranges);
ranges.sort_by_key(|v| *v.start());
println!("Ranges: {:?}", ranges);
let ids: Vec<_> = CONTENT.lines().map(|l| l.trim()).skip_while(|l| !l.is_empty()).skip(1).map(|v| v.parse::<usize>().unwrap()).collect();
println!("IDs: {:?}", ids);
let fresh = ids.iter().filter(|id| {
for r in ranges.iter() {
if r.start() > id {
return false;
}
if r.contains(id) {
return true;
}
}
false
}).count();
println!("Fresh: {:?}", fresh);
}

1191
2025/inputs/05_1.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
3-5
10-14
16-20
12-18
1
5
8
11
17
32