We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cea5453 commit 7827550Copy full SHA for 7827550
src/aoc/y2025/day02.rs
@@ -62,17 +62,14 @@ pub fn part_2(data: crate::DataIn) -> crate::AoCResult<String> {
62
let len = numstr.len();
63
let max_len = len / 2;
64
65
- // This takes 4 seconds but whatever 😭
66
(1..=max_len)
67
// Filter out any number that can't make valid windows
68
.filter(|size| len % size == 0)
69
.any(|size| {
70
let substr = &numstr[0..size];
71
- numstr
72
- .chars()
73
- .chunks(size)
74
- .into_iter()
75
- .all(|window| window.collect::<String>() == substr)
+ (size..=len - size)
+ .step_by(size)
+ .all(|start| &numstr[start..start + size] == substr)
76
})
77
78
0 commit comments