From 308ddd0de45584d5148436077eac4e1c2045b2b1 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 6 Dec 2022 05:27:57 +0100 Subject: [PATCH] Split with two different seperators instead of replacing first --- 2022/src/bin/day4.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/2022/src/bin/day4.rs b/2022/src/bin/day4.rs index 5da9587..a1d2304 100644 --- a/2022/src/bin/day4.rs +++ b/2022/src/bin/day4.rs @@ -75,8 +75,7 @@ fn overlaps((a, b): &(Elf, Elf)) -> bool { // Transform from line to pair of Elfs fn transform(s: &str) -> (Elf, Elf) { let transformed = s - .replace("-", ",") - .split(',') + .split([',', '-']) .flat_map(|value| value.parse::()) .collect::>();