From 9cf06a535dcb48fa0891407ac8a9899497b82f7d Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 17 Dec 2021 11:42:47 -0600 Subject: [PATCH] Reduce problem space --- 2021/rust/day17.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/2021/rust/day17.rs b/2021/rust/day17.rs index 8e71da1..7dd6be5 100644 --- a/2021/rust/day17.rs +++ b/2021/rust/day17.rs @@ -62,14 +62,16 @@ fn trick_shot(r: &Rect) -> (Option, i64) { let mut result = None; let mut valid_shots = 0; for x in 1..=r.bottom_right.x { - for y in r.bottom_right.y..=2000 { + for y in r.bottom_right.y..=-r.bottom_right.y*2 { println!("Simulating {}, {}", x, y); if let Ok((v, hy)) = simulate_shot(Vec2 { x, y }, r) { valid_shots += 1; if result.is_some() { - if hy > result.unwrap() { result = Some(hy); } + if hy > result.unwrap() { + println!("!! New Highest Y: {} via {}, {}", hy, x, y); + result = Some(hy); + } } else { - println!("!! New Highest Y: {} via {}, {}", hy, x, y); result = Some(hy); } }