From 3a1181d97393695a66cd154f263eb2cbdc210fdc Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Sat, 17 Dec 2022 06:01:17 +0100 Subject: [PATCH] Better conditional assignment --- 2022/src/bin/day15.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/2022/src/bin/day15.rs b/2022/src/bin/day15.rs index 6e1d7c4..d464a89 100644 --- a/2022/src/bin/day15.rs +++ b/2022/src/bin/day15.rs @@ -188,12 +188,11 @@ impl aoc::Solver for Day { .flat_map(Sensor::from_str) .collect::>(); - let y_level; - if input.lines().count() > 14 { - y_level = 2000000; + let y_level = if input.lines().count() > 14 { + 2000000 } else { - y_level = 10; - } + 10 + }; get_ranges(&sensors, y_level, true) .iter() @@ -207,12 +206,12 @@ impl aoc::Solver for Day { .lines() .flat_map(Sensor::from_str) .collect::>(); - let max; - if input.lines().count() > 14 { - max = 4000000; + + let max = if input.lines().count() > 14 { + 4000000 } else { - max = 20; - } + 20 + }; for y_level in 0..(max+1) { let ranges = get_ranges(&sensors, y_level, false);