From f9819ba6b5a59dc78deb539ecc4ff88ed0f692b7 Mon Sep 17 00:00:00 2001 From: alyx Date: Mon, 4 Dec 2023 02:04:09 -0500 Subject: Optimise 2023.4 --- 2023/rs/code/four/src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to '2023/rs/code') 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() }); -- cgit v1.2.3-70-g09d2