From 4fe7654d75d702171919b43e98ff76753f803f59 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Fri, 28 May 2021 16:13:59 -0400 Subject: [PATCH] Updated Algorithms --- src/Problems/Problem28.rs | 2 +- src/Problems/Problem30.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Problems/Problem28.rs b/src/Problems/Problem28.rs index 353e9e9..bae066f 100644 --- a/src/Problems/Problem28.rs +++ b/src/Problems/Problem28.rs @@ -26,7 +26,7 @@ extern crate myClasses; use crate::Problems::Answer::Answer; pub fn getDescription() -> String{ - "What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed by starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral".to_string() + "What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed by starting with the number 1 and moving to the right in a clockwise direction?".to_string() } pub fn solve() -> Answer{ diff --git a/src/Problems/Problem30.rs b/src/Problems/Problem30.rs index e789f81..85f9870 100644 --- a/src/Problems/Problem30.rs +++ b/src/Problems/Problem30.rs @@ -55,11 +55,13 @@ pub fn solve() -> Answer{ } } + let sum = sumOfFifthNumbers.iter().sum::(); + //Stop the timer timer.stop(); //Return the results - return Answer::new(format!("The sum of all the numbers that can be written as the sum of the fifth powers of their digits is {}", sumOfFifthNumbers.iter().sum::()), timer.getString(), timer.getNano()); + return Answer::new(format!("The sum of all the numbers that can be written as the sum of the fifth powers of their digits is {}", sum), timer.getString(), timer.getNano()); } //Returns a vector with the individual digits of the number passed to it fn getDigits(num: i64) -> Vec::{