From da219ec692a7cdc9091f528ca34fb84dd139de49 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Sat, 3 Oct 2020 12:52:19 -0400 Subject: [PATCH] Fixed typos --- .../mattrixwv/ProjectEuler/Problems/Problem22.java | 8 ++------ .../mattrixwv/ProjectEuler/Problems/Problem26.java | 10 ++++------ .../mattrixwv/ProjectEuler/Problems/Problem27.java | 4 ++-- .../mattrixwv/ProjectEuler/Problems/Problem67.java | 2 +- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem22.java b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem22.java index eab9926..febec16 100644 --- a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem22.java +++ b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem22.java @@ -470,11 +470,7 @@ public class Problem22 extends Problem{ return String.format("The answer to the question is %d", sum); } //Returns the vector of the names being scored - public ArrayList getNames(){ - //If the problem hasn't been solved throw an exception - if(!solved){ - throw new Unsolved(); - } + public static ArrayList getNames(){ return names; } //Returns the sum of the names scores @@ -483,7 +479,7 @@ public class Problem22 extends Problem{ if(!solved){ throw new Unsolved(); } - return Algorithms.getLongSum(prod); + return sum; } } diff --git a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem26.java b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem26.java index 4309e4e..171664b 100644 --- a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem26.java +++ b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem26.java @@ -59,19 +59,17 @@ public class Problem26 extends Problem{ //Loop through every number from 2-999 and use it for the denominator for(int denominator = 2;denominator <= TOP_NUM;++denominator){ ArrayList denomList = new ArrayList(); - boolean endFound = false; //Holds whether we have found an end to the number (either a cycle or a 0 for remainder) - boolean cycleFound = false; //Holds whether a cycle was detected + boolean endFound = false; //A flag for when we have found an end to the number (either a cycle or a 0 for remainder) + boolean cycleFound = false; //A flag to indicate a cycle was detected int numerator = 1; //The numerator that will be divided. Always starts at 1 while(!endFound){ //Get the remainder after the division int remainder = numerator % denominator; - //Check if the remainder is 0 - //If it is set the flag + //Check if the remainder is 0 and set the flag if(remainder == 0){ endFound = true; } - //Check if the remainder is in the list - //If it is in the list, set the appropriate flags + //Check if the remainder is in the list and set the appropriate flags else if(Algorithms.isFound(denomList, remainder)){ endFound = true; cycleFound = true; diff --git a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem27.java b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem27.java index f77a140..acea19a 100644 --- a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem27.java +++ b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem27.java @@ -32,8 +32,8 @@ import java.util.ArrayList; public class Problem27 extends Problem{ //Variables //Static varibles - private static int LARGEST_POSSIBLE_A = 999; - private static int LARGEST_POSSIBLE_B = 1000; + private static final int LARGEST_POSSIBLE_A = 999; + private static final int LARGEST_POSSIBLE_B = 1000; //Instance variables private int topA; //The A for the most n's generated private int topB; //The B for the most n's generated diff --git a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem67.java b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem67.java index 4ce39e6..0dedf46 100644 --- a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem67.java +++ b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem67.java @@ -1,7 +1,7 @@ //ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem67.java //Matthew Ellison // Created: 03-26-19 -//Modified: 07-196-20 +//Modified: 07-19-20 //Find the maximum total from top to bottom /* 59