diff --git a/rs/src/y2022/d14.rs b/rs/src/y2022/d14.rs index 35e6243..47d3123 100644 --- a/rs/src/y2022/d14.rs +++ b/rs/src/y2022/d14.rs @@ -81,9 +81,8 @@ fn draw_floor(grid: &mut Grid) { /// /// This function will return `true` if it managed to deposit a unit of sand. fn drop(grid: &mut Grid, path: &mut Vec<(i32, i32)>, max_y: i32) -> bool { - let (mut x, mut y) = match path.last() { - Some(pos) => pos, - None => return false, + let Some((mut x, mut y)) = path.last() else { + return false; }; loop { diff --git a/rs/src/y2022/d15.rs b/rs/src/y2022/d15.rs index 7986a13..00440ff 100644 --- a/rs/src/y2022/d15.rs +++ b/rs/src/y2022/d15.rs @@ -126,7 +126,7 @@ pub fn solve(input: String) { lines_trbl.push((p.0 + d + 1, p.1, p.0, p.1 + d + 1)); } - for tlbr in &lines_tlbr { + 'outer: for tlbr in &lines_tlbr { for trbl in &lines_trbl { if let Some(intersect) = intersect_lines(*tlbr, *trbl) { let x_in_bounds = 0 <= intersect.0 && intersect.0 <= 4000000; @@ -147,7 +147,7 @@ pub fn solve(input: String) { // We found our candidate :) let tuning_frequency = intersect.0 as i64 * 4000000 + intersect.1 as i64; println!("Part 2: {tuning_frequency}"); - return; + break 'outer; } } }