summaryrefslogtreecommitdiffstats
path: root/2023/rs/code
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2023-12-04 02:04:09 -0500
committeralyx <alyx@aleteoryx.me>2023-12-04 02:04:09 -0500
commitf9819ba6b5a59dc78deb539ecc4ff88ed0f692b7 (patch)
tree560c9644344f96428d5794d79c79e8af58e09faa /2023/rs/code
parent3438b040ad18b362e5a4d8576d11be462d841432 (diff)
downloadadventofcode-f9819ba6b5a59dc78deb539ecc4ff88ed0f692b7.tar.gz
adventofcode-f9819ba6b5a59dc78deb539ecc4ff88ed0f692b7.tar.bz2
adventofcode-f9819ba6b5a59dc78deb539ecc4ff88ed0f692b7.zip
Optimise 2023.4
Diffstat (limited to '2023/rs/code')
-rw-r--r--2023/rs/code/four/src/main.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/2023/rs/code/four/src/main.rs b/2023/rs/code/four/src/main.rs
index 7508e4a..328d84a 100644
--- a/2023/rs/code/four/src/main.rs
+++ b/2023/rs/code/four/src/main.rs
@@ -9,11 +9,10 @@ fn parse_val(s: &[u8]) -> u8 {
}
fn main() {
- let valueified = INPUT.split(|b| *b == b'\n').filter(|s| !s.is_empty())
+ let valueified = INPUT.array_chunks::<117>()
.map(|b| {
let win: u128 = b[10..40].array_chunks::<3>().fold(0, |a, b| a | (1 << parse_val(&b[0..2])));
- let valiter = b[42..].array_chunks::<3>();
- let val: u128 = valiter.clone().fold(0, |a, b| a | (1 << parse_val(&b[0..2]))) | (1 << parse_val(valiter.remainder()));
+ let val: u128 = b[42..].array_chunks::<3>().fold(0, |a, b| a | (1 << parse_val(&b[0..2])));
(win & val).count_ones()
});