From 149cec0f2a49c3124cb7422a9a201e2338d38525 Mon Sep 17 00:00:00 2001 From: nekineki Date: Thu, 7 Dec 2023 11:43:05 +0100 Subject: day06 fix float logic --- 2023/day06.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '2023') diff --git a/2023/day06.rs b/2023/day06.rs index 839c798..93ffec5 100644 --- a/2023/day06.rs +++ b/2023/day06.rs @@ -6,9 +6,9 @@ fn get_opts(t: u64, d: u64) -> u64 { let t = t as f64; let d = d as f64; let D = f64::sqrt((t * t - 4. * d) as f64); - let x1 = ((-t - D) / 2.).floor(); + let x1 = ((-t - D) / 2.).ceil(); let x2 = ((-t + D) / 2.).floor(); - (x2 - x1) as u64 + (x2 - x1 + 1.) as u64 } fn main() { -- cgit v1.2.3