From 0e85c328baaacca80345c35f09238175a452406c Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Fri, 6 Dec 2024 14:04:31 +0000 Subject: [PATCH] refactor: various changes using clippy --- src/bin/coded_triangle_numbers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/coded_triangle_numbers.rs b/src/bin/coded_triangle_numbers.rs index b6e81db..1333edf 100644 --- a/src/bin/coded_triangle_numbers.rs +++ b/src/bin/coded_triangle_numbers.rs @@ -10,7 +10,7 @@ fn main() { let mut contents = fs::read_to_string("assets/input") .expect("Could not read the input file").replace("\"\n", ""); - if contents.len() > 0 { + if !contents.is_empty() { contents.remove(0); } let words = contents.split("\",\"").collect::>(); @@ -23,7 +23,7 @@ fn main() { total_index += index; } - let position: f64 = ((-1 as f64)+(((1+8*total_index) as f64).sqrt() as f64))/2.; + let position: f64 = (-1_f64+((1+8*total_index) as f64).sqrt())/2.; if position.fract() == 0. { triangles += 1; }