From 96d18f3eda19375b1d0bb2d28f7cafb4e7e5ebd6 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Tue, 16 Jun 2020 12:22:38 -0400 Subject: [PATCH] Changed code to compare more easily with others --- Headers/Problem13.hpp | 3 ++- Source/Problem13.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Headers/Problem13.hpp b/Headers/Problem13.hpp index 5205d51..4eec30f 100644 --- a/Headers/Problem13.hpp +++ b/Headers/Problem13.hpp @@ -142,6 +142,7 @@ private: //A vector to hold all of the numbers static std::vector nums; mpz_class sum; + void setNums(); public: Problem13(); virtual void solve(); @@ -156,7 +157,7 @@ public: /* Results: The sum of all 100 numbers is 5537376230390876637302048746832985971773659831892672 The first 10 digits of the sum of the numbers is 5537376230 -It took 10.000 microseconds to solve this problem. +It took 0.000 nanoseconds to solve this problem. */ #endif //PROBLEM13_HPP diff --git a/Source/Problem13.cpp b/Source/Problem13.cpp index b7ca8fc..276e058 100644 --- a/Source/Problem13.cpp +++ b/Source/Problem13.cpp @@ -144,6 +144,9 @@ Problem13::Problem13() : Problem("Work out the first ten digits of the sum of th //Make sure the vector is the correct size nums.reserve(100); nums.resize(100); +} + +void Problem13::setNums(){ //Set the numbers nums[0] = "37107287533902102798797998220837590246510135740250"; nums[1] = "46376937677490009712648124896970078050417018260538"; @@ -256,6 +259,9 @@ void Problem13::solve(){ //Start the timer timer.start(); + //Setup the array + setNums(); + //Get the sum of all the numbers sum = mee::getSum(nums);