mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-06 17:13:58 -05:00
Made all programs similar
This commit is contained in:
@@ -143,15 +143,16 @@ public class Problem13 extends Problem{
|
||||
super("Work out the first ten digits of the sum of the one-hundred 50-digit numbers");
|
||||
nums = new ArrayList<BigInteger>();
|
||||
reserveVectors();
|
||||
setNums();
|
||||
sum = BigInteger.ZERO;
|
||||
}
|
||||
//Operational functions
|
||||
//A function to set the nums vector
|
||||
private void setNums(){
|
||||
private void reserveVectors(){
|
||||
nums.ensureCapacity(100);
|
||||
}
|
||||
//Reserve the size of the vector to speed up insertion
|
||||
private void reserveVectors(){
|
||||
private void setNums(){
|
||||
//Setup the array
|
||||
nums.add(new BigInteger("37107287533902102798797998220837590246510135740250"));
|
||||
nums.add(new BigInteger("46376937677490009712648124896970078050417018260538"));
|
||||
@@ -265,9 +266,6 @@ public class Problem13 extends Problem{
|
||||
//Start the timer
|
||||
timer.start();
|
||||
|
||||
//Setup the array
|
||||
setNums();
|
||||
|
||||
|
||||
//Get the sum of all the numbers
|
||||
sum = ArrayAlgorithms.getBigSum(nums);
|
||||
@@ -286,6 +284,7 @@ public class Problem13 extends Problem{
|
||||
sum = BigInteger.ZERO;
|
||||
nums.clear();
|
||||
reserveVectors();
|
||||
setNums();
|
||||
}
|
||||
//Gets
|
||||
//Returns the result of solving the problem
|
||||
|
||||
Reference in New Issue
Block a user