diff --git a/files/Problem42Words.txt b/files/Problem42Words.txt new file mode 100644 index 0000000..7177624 --- /dev/null +++ b/files/Problem42Words.txt @@ -0,0 +1 @@ +"A","ABILITY","ABLE","ABOUT","ABOVE","ABSENCE","ABSOLUTELY","ACADEMIC","ACCEPT","ACCESS","ACCIDENT","ACCOMPANY","ACCORDING","ACCOUNT","ACHIEVE","ACHIEVEMENT","ACID","ACQUIRE","ACROSS","ACT","ACTION","ACTIVE","ACTIVITY","ACTUAL","ACTUALLY","ADD","ADDITION","ADDITIONAL","ADDRESS","ADMINISTRATION","ADMIT","ADOPT","ADULT","ADVANCE","ADVANTAGE","ADVICE","ADVISE","AFFAIR","AFFECT","AFFORD","AFRAID","AFTER","AFTERNOON","AFTERWARDS","AGAIN","AGAINST","AGE","AGENCY","AGENT","AGO","AGREE","AGREEMENT","AHEAD","AID","AIM","AIR","AIRCRAFT","ALL","ALLOW","ALMOST","ALONE","ALONG","ALREADY","ALRIGHT","ALSO","ALTERNATIVE","ALTHOUGH","ALWAYS","AMONG","AMONGST","AMOUNT","AN","ANALYSIS","ANCIENT","AND","ANIMAL","ANNOUNCE","ANNUAL","ANOTHER","ANSWER","ANY","ANYBODY","ANYONE","ANYTHING","ANYWAY","APART","APPARENT","APPARENTLY","APPEAL","APPEAR","APPEARANCE","APPLICATION","APPLY","APPOINT","APPOINTMENT","APPROACH","APPROPRIATE","APPROVE","AREA","ARGUE","ARGUMENT","ARISE","ARM","ARMY","AROUND","ARRANGE","ARRANGEMENT","ARRIVE","ART","ARTICLE","ARTIST","AS","ASK","ASPECT","ASSEMBLY","ASSESS","ASSESSMENT","ASSET","ASSOCIATE","ASSOCIATION","ASSUME","ASSUMPTION","AT","ATMOSPHERE","ATTACH","ATTACK","ATTEMPT","ATTEND","ATTENTION","ATTITUDE","ATTRACT","ATTRACTIVE","AUDIENCE","AUTHOR","AUTHORITY","AVAILABLE","AVERAGE","AVOID","AWARD","AWARE","AWAY","AYE","BABY","BACK","BACKGROUND","BAD","BAG","BALANCE","BALL","BAND","BANK","BAR","BASE","BASIC","BASIS","BATTLE","BE","BEAR","BEAT","BEAUTIFUL","BECAUSE","BECOME","BED","BEDROOM","BEFORE","BEGIN","BEGINNING","BEHAVIOUR","BEHIND","BELIEF","BELIEVE","BELONG","BELOW","BENEATH","BENEFIT","BESIDE","BEST","BETTER","BETWEEN","BEYOND","BIG","BILL","BIND","BIRD","BIRTH","BIT","BLACK","BLOCK","BLOOD","BLOODY","BLOW","BLUE","BOARD","BOAT","BODY","BONE","BOOK","BORDER","BOTH","BOTTLE","BOTTOM","BOX","BOY","BRAIN","BRANCH","BREAK","BREATH","BRIDGE","BRIEF","BRIGHT","BRING","BROAD","BROTHER","BUDGET","BUILD","BUILDING","BURN","BUS","BUSINESS","BUSY","BUT","BUY","BY","CABINET","CALL","CAMPAIGN","CAN","CANDIDATE","CAPABLE","CAPACITY","CAPITAL","CAR","CARD","CARE","CAREER","CAREFUL","CAREFULLY","CARRY","CASE","CASH","CAT","CATCH","CATEGORY","CAUSE","CELL","CENTRAL","CENTRE","CENTURY","CERTAIN","CERTAINLY","CHAIN","CHAIR","CHAIRMAN","CHALLENGE","CHANCE","CHANGE","CHANNEL","CHAPTER","CHARACTER","CHARACTERISTIC","CHARGE","CHEAP","CHECK","CHEMICAL","CHIEF","CHILD","CHOICE","CHOOSE","CHURCH","CIRCLE","CIRCUMSTANCE","CITIZEN","CITY","CIVIL","CLAIM","CLASS","CLEAN","CLEAR","CLEARLY","CLIENT","CLIMB","CLOSE","CLOSELY","CLOTHES","CLUB","COAL","CODE","COFFEE","COLD","COLLEAGUE","COLLECT","COLLECTION","COLLEGE","COLOUR","COMBINATION","COMBINE","COME","COMMENT","COMMERCIAL","COMMISSION","COMMIT","COMMITMENT","COMMITTEE","COMMON","COMMUNICATION","COMMUNITY","COMPANY","COMPARE","COMPARISON","COMPETITION","COMPLETE","COMPLETELY","COMPLEX","COMPONENT","COMPUTER","CONCENTRATE","CONCENTRATION","CONCEPT","CONCERN","CONCERNED","CONCLUDE","CONCLUSION","CONDITION","CONDUCT","CONFERENCE","CONFIDENCE","CONFIRM","CONFLICT","CONGRESS","CONNECT","CONNECTION","CONSEQUENCE","CONSERVATIVE","CONSIDER","CONSIDERABLE","CONSIDERATION","CONSIST","CONSTANT","CONSTRUCTION","CONSUMER","CONTACT","CONTAIN","CONTENT","CONTEXT","CONTINUE","CONTRACT","CONTRAST","CONTRIBUTE","CONTRIBUTION","CONTROL","CONVENTION","CONVERSATION","COPY","CORNER","CORPORATE","CORRECT","COS","COST","COULD","COUNCIL","COUNT","COUNTRY","COUNTY","COUPLE","COURSE","COURT","COVER","CREATE","CREATION","CREDIT","CRIME","CRIMINAL","CRISIS","CRITERION","CRITICAL","CRITICISM","CROSS","CROWD","CRY","CULTURAL","CULTURE","CUP","CURRENT","CURRENTLY","CURRICULUM","CUSTOMER","CUT","DAMAGE","DANGER","DANGEROUS","DARK","DATA","DATE","DAUGHTER","DAY","DEAD","DEAL","DEATH","DEBATE","DEBT","DECADE","DECIDE","DECISION","DECLARE","DEEP","DEFENCE","DEFENDANT","DEFINE","DEFINITION","DEGREE","DELIVER","DEMAND","DEMOCRATIC","DEMONSTRATE","DENY","DEPARTMENT","DEPEND","DEPUTY","DERIVE","DESCRIBE","DESCRIPTION","DESIGN","DESIRE","DESK","DESPITE","DESTROY","DETAIL","DETAILED","DETERMINE","DEVELOP","DEVELOPMENT","DEVICE","DIE","DIFFERENCE","DIFFERENT","DIFFICULT","DIFFICULTY","DINNER","DIRECT","DIRECTION","DIRECTLY","DIRECTOR","DISAPPEAR","DISCIPLINE","DISCOVER","DISCUSS","DISCUSSION","DISEASE","DISPLAY","DISTANCE","DISTINCTION","DISTRIBUTION","DISTRICT","DIVIDE","DIVISION","DO","DOCTOR","DOCUMENT","DOG","DOMESTIC","DOOR","DOUBLE","DOUBT","DOWN","DRAW","DRAWING","DREAM","DRESS","DRINK","DRIVE","DRIVER","DROP","DRUG","DRY","DUE","DURING","DUTY","EACH","EAR","EARLY","EARN","EARTH","EASILY","EAST","EASY","EAT","ECONOMIC","ECONOMY","EDGE","EDITOR","EDUCATION","EDUCATIONAL","EFFECT","EFFECTIVE","EFFECTIVELY","EFFORT","EGG","EITHER","ELDERLY","ELECTION","ELEMENT","ELSE","ELSEWHERE","EMERGE","EMPHASIS","EMPLOY","EMPLOYEE","EMPLOYER","EMPLOYMENT","EMPTY","ENABLE","ENCOURAGE","END","ENEMY","ENERGY","ENGINE","ENGINEERING","ENJOY","ENOUGH","ENSURE","ENTER","ENTERPRISE","ENTIRE","ENTIRELY","ENTITLE","ENTRY","ENVIRONMENT","ENVIRONMENTAL","EQUAL","EQUALLY","EQUIPMENT","ERROR","ESCAPE","ESPECIALLY","ESSENTIAL","ESTABLISH","ESTABLISHMENT","ESTATE","ESTIMATE","EVEN","EVENING","EVENT","EVENTUALLY","EVER","EVERY","EVERYBODY","EVERYONE","EVERYTHING","EVIDENCE","EXACTLY","EXAMINATION","EXAMINE","EXAMPLE","EXCELLENT","EXCEPT","EXCHANGE","EXECUTIVE","EXERCISE","EXHIBITION","EXIST","EXISTENCE","EXISTING","EXPECT","EXPECTATION","EXPENDITURE","EXPENSE","EXPENSIVE","EXPERIENCE","EXPERIMENT","EXPERT","EXPLAIN","EXPLANATION","EXPLORE","EXPRESS","EXPRESSION","EXTEND","EXTENT","EXTERNAL","EXTRA","EXTREMELY","EYE","FACE","FACILITY","FACT","FACTOR","FACTORY","FAIL","FAILURE","FAIR","FAIRLY","FAITH","FALL","FAMILIAR","FAMILY","FAMOUS","FAR","FARM","FARMER","FASHION","FAST","FATHER","FAVOUR","FEAR","FEATURE","FEE","FEEL","FEELING","FEMALE","FEW","FIELD","FIGHT","FIGURE","FILE","FILL","FILM","FINAL","FINALLY","FINANCE","FINANCIAL","FIND","FINDING","FINE","FINGER","FINISH","FIRE","FIRM","FIRST","FISH","FIT","FIX","FLAT","FLIGHT","FLOOR","FLOW","FLOWER","FLY","FOCUS","FOLLOW","FOLLOWING","FOOD","FOOT","FOOTBALL","FOR","FORCE","FOREIGN","FOREST","FORGET","FORM","FORMAL","FORMER","FORWARD","FOUNDATION","FREE","FREEDOM","FREQUENTLY","FRESH","FRIEND","FROM","FRONT","FRUIT","FUEL","FULL","FULLY","FUNCTION","FUND","FUNNY","FURTHER","FUTURE","GAIN","GAME","GARDEN","GAS","GATE","GATHER","GENERAL","GENERALLY","GENERATE","GENERATION","GENTLEMAN","GET","GIRL","GIVE","GLASS","GO","GOAL","GOD","GOLD","GOOD","GOVERNMENT","GRANT","GREAT","GREEN","GREY","GROUND","GROUP","GROW","GROWING","GROWTH","GUEST","GUIDE","GUN","HAIR","HALF","HALL","HAND","HANDLE","HANG","HAPPEN","HAPPY","HARD","HARDLY","HATE","HAVE","HE","HEAD","HEALTH","HEAR","HEART","HEAT","HEAVY","HELL","HELP","HENCE","HER","HERE","HERSELF","HIDE","HIGH","HIGHLY","HILL","HIM","HIMSELF","HIS","HISTORICAL","HISTORY","HIT","HOLD","HOLE","HOLIDAY","HOME","HOPE","HORSE","HOSPITAL","HOT","HOTEL","HOUR","HOUSE","HOUSEHOLD","HOUSING","HOW","HOWEVER","HUGE","HUMAN","HURT","HUSBAND","I","IDEA","IDENTIFY","IF","IGNORE","ILLUSTRATE","IMAGE","IMAGINE","IMMEDIATE","IMMEDIATELY","IMPACT","IMPLICATION","IMPLY","IMPORTANCE","IMPORTANT","IMPOSE","IMPOSSIBLE","IMPRESSION","IMPROVE","IMPROVEMENT","IN","INCIDENT","INCLUDE","INCLUDING","INCOME","INCREASE","INCREASED","INCREASINGLY","INDEED","INDEPENDENT","INDEX","INDICATE","INDIVIDUAL","INDUSTRIAL","INDUSTRY","INFLUENCE","INFORM","INFORMATION","INITIAL","INITIATIVE","INJURY","INSIDE","INSIST","INSTANCE","INSTEAD","INSTITUTE","INSTITUTION","INSTRUCTION","INSTRUMENT","INSURANCE","INTEND","INTENTION","INTEREST","INTERESTED","INTERESTING","INTERNAL","INTERNATIONAL","INTERPRETATION","INTERVIEW","INTO","INTRODUCE","INTRODUCTION","INVESTIGATE","INVESTIGATION","INVESTMENT","INVITE","INVOLVE","IRON","IS","ISLAND","ISSUE","IT","ITEM","ITS","ITSELF","JOB","JOIN","JOINT","JOURNEY","JUDGE","JUMP","JUST","JUSTICE","KEEP","KEY","KID","KILL","KIND","KING","KITCHEN","KNEE","KNOW","KNOWLEDGE","LABOUR","LACK","LADY","LAND","LANGUAGE","LARGE","LARGELY","LAST","LATE","LATER","LATTER","LAUGH","LAUNCH","LAW","LAWYER","LAY","LEAD","LEADER","LEADERSHIP","LEADING","LEAF","LEAGUE","LEAN","LEARN","LEAST","LEAVE","LEFT","LEG","LEGAL","LEGISLATION","LENGTH","LESS","LET","LETTER","LEVEL","LIABILITY","LIBERAL","LIBRARY","LIE","LIFE","LIFT","LIGHT","LIKE","LIKELY","LIMIT","LIMITED","LINE","LINK","LIP","LIST","LISTEN","LITERATURE","LITTLE","LIVE","LIVING","LOAN","LOCAL","LOCATION","LONG","LOOK","LORD","LOSE","LOSS","LOT","LOVE","LOVELY","LOW","LUNCH","MACHINE","MAGAZINE","MAIN","MAINLY","MAINTAIN","MAJOR","MAJORITY","MAKE","MALE","MAN","MANAGE","MANAGEMENT","MANAGER","MANNER","MANY","MAP","MARK","MARKET","MARRIAGE","MARRIED","MARRY","MASS","MASTER","MATCH","MATERIAL","MATTER","MAY","MAYBE","ME","MEAL","MEAN","MEANING","MEANS","MEANWHILE","MEASURE","MECHANISM","MEDIA","MEDICAL","MEET","MEETING","MEMBER","MEMBERSHIP","MEMORY","MENTAL","MENTION","MERELY","MESSAGE","METAL","METHOD","MIDDLE","MIGHT","MILE","MILITARY","MILK","MIND","MINE","MINISTER","MINISTRY","MINUTE","MISS","MISTAKE","MODEL","MODERN","MODULE","MOMENT","MONEY","MONTH","MORE","MORNING","MOST","MOTHER","MOTION","MOTOR","MOUNTAIN","MOUTH","MOVE","MOVEMENT","MUCH","MURDER","MUSEUM","MUSIC","MUST","MY","MYSELF","NAME","NARROW","NATION","NATIONAL","NATURAL","NATURE","NEAR","NEARLY","NECESSARILY","NECESSARY","NECK","NEED","NEGOTIATION","NEIGHBOUR","NEITHER","NETWORK","NEVER","NEVERTHELESS","NEW","NEWS","NEWSPAPER","NEXT","NICE","NIGHT","NO","NOBODY","NOD","NOISE","NONE","NOR","NORMAL","NORMALLY","NORTH","NORTHERN","NOSE","NOT","NOTE","NOTHING","NOTICE","NOTION","NOW","NUCLEAR","NUMBER","NURSE","OBJECT","OBJECTIVE","OBSERVATION","OBSERVE","OBTAIN","OBVIOUS","OBVIOUSLY","OCCASION","OCCUR","ODD","OF","OFF","OFFENCE","OFFER","OFFICE","OFFICER","OFFICIAL","OFTEN","OIL","OKAY","OLD","ON","ONCE","ONE","ONLY","ONTO","OPEN","OPERATE","OPERATION","OPINION","OPPORTUNITY","OPPOSITION","OPTION","OR","ORDER","ORDINARY","ORGANISATION","ORGANISE","ORGANIZATION","ORIGIN","ORIGINAL","OTHER","OTHERWISE","OUGHT","OUR","OURSELVES","OUT","OUTCOME","OUTPUT","OUTSIDE","OVER","OVERALL","OWN","OWNER","PACKAGE","PAGE","PAIN","PAINT","PAINTING","PAIR","PANEL","PAPER","PARENT","PARK","PARLIAMENT","PART","PARTICULAR","PARTICULARLY","PARTLY","PARTNER","PARTY","PASS","PASSAGE","PAST","PATH","PATIENT","PATTERN","PAY","PAYMENT","PEACE","PENSION","PEOPLE","PER","PERCENT","PERFECT","PERFORM","PERFORMANCE","PERHAPS","PERIOD","PERMANENT","PERSON","PERSONAL","PERSUADE","PHASE","PHONE","PHOTOGRAPH","PHYSICAL","PICK","PICTURE","PIECE","PLACE","PLAN","PLANNING","PLANT","PLASTIC","PLATE","PLAY","PLAYER","PLEASE","PLEASURE","PLENTY","PLUS","POCKET","POINT","POLICE","POLICY","POLITICAL","POLITICS","POOL","POOR","POPULAR","POPULATION","POSITION","POSITIVE","POSSIBILITY","POSSIBLE","POSSIBLY","POST","POTENTIAL","POUND","POWER","POWERFUL","PRACTICAL","PRACTICE","PREFER","PREPARE","PRESENCE","PRESENT","PRESIDENT","PRESS","PRESSURE","PRETTY","PREVENT","PREVIOUS","PREVIOUSLY","PRICE","PRIMARY","PRIME","PRINCIPLE","PRIORITY","PRISON","PRISONER","PRIVATE","PROBABLY","PROBLEM","PROCEDURE","PROCESS","PRODUCE","PRODUCT","PRODUCTION","PROFESSIONAL","PROFIT","PROGRAM","PROGRAMME","PROGRESS","PROJECT","PROMISE","PROMOTE","PROPER","PROPERLY","PROPERTY","PROPORTION","PROPOSE","PROPOSAL","PROSPECT","PROTECT","PROTECTION","PROVE","PROVIDE","PROVIDED","PROVISION","PUB","PUBLIC","PUBLICATION","PUBLISH","PULL","PUPIL","PURPOSE","PUSH","PUT","QUALITY","QUARTER","QUESTION","QUICK","QUICKLY","QUIET","QUITE","RACE","RADIO","RAILWAY","RAIN","RAISE","RANGE","RAPIDLY","RARE","RATE","RATHER","REACH","REACTION","READ","READER","READING","READY","REAL","REALISE","REALITY","REALIZE","REALLY","REASON","REASONABLE","RECALL","RECEIVE","RECENT","RECENTLY","RECOGNISE","RECOGNITION","RECOGNIZE","RECOMMEND","RECORD","RECOVER","RED","REDUCE","REDUCTION","REFER","REFERENCE","REFLECT","REFORM","REFUSE","REGARD","REGION","REGIONAL","REGULAR","REGULATION","REJECT","RELATE","RELATION","RELATIONSHIP","RELATIVE","RELATIVELY","RELEASE","RELEVANT","RELIEF","RELIGION","RELIGIOUS","RELY","REMAIN","REMEMBER","REMIND","REMOVE","REPEAT","REPLACE","REPLY","REPORT","REPRESENT","REPRESENTATION","REPRESENTATIVE","REQUEST","REQUIRE","REQUIREMENT","RESEARCH","RESOURCE","RESPECT","RESPOND","RESPONSE","RESPONSIBILITY","RESPONSIBLE","REST","RESTAURANT","RESULT","RETAIN","RETURN","REVEAL","REVENUE","REVIEW","REVOLUTION","RICH","RIDE","RIGHT","RING","RISE","RISK","RIVER","ROAD","ROCK","ROLE","ROLL","ROOF","ROOM","ROUND","ROUTE","ROW","ROYAL","RULE","RUN","RURAL","SAFE","SAFETY","SALE","SAME","SAMPLE","SATISFY","SAVE","SAY","SCALE","SCENE","SCHEME","SCHOOL","SCIENCE","SCIENTIFIC","SCIENTIST","SCORE","SCREEN","SEA","SEARCH","SEASON","SEAT","SECOND","SECONDARY","SECRETARY","SECTION","SECTOR","SECURE","SECURITY","SEE","SEEK","SEEM","SELECT","SELECTION","SELL","SEND","SENIOR","SENSE","SENTENCE","SEPARATE","SEQUENCE","SERIES","SERIOUS","SERIOUSLY","SERVANT","SERVE","SERVICE","SESSION","SET","SETTLE","SETTLEMENT","SEVERAL","SEVERE","SEX","SEXUAL","SHAKE","SHALL","SHAPE","SHARE","SHE","SHEET","SHIP","SHOE","SHOOT","SHOP","SHORT","SHOT","SHOULD","SHOULDER","SHOUT","SHOW","SHUT","SIDE","SIGHT","SIGN","SIGNAL","SIGNIFICANCE","SIGNIFICANT","SILENCE","SIMILAR","SIMPLE","SIMPLY","SINCE","SING","SINGLE","SIR","SISTER","SIT","SITE","SITUATION","SIZE","SKILL","SKIN","SKY","SLEEP","SLIGHTLY","SLIP","SLOW","SLOWLY","SMALL","SMILE","SO","SOCIAL","SOCIETY","SOFT","SOFTWARE","SOIL","SOLDIER","SOLICITOR","SOLUTION","SOME","SOMEBODY","SOMEONE","SOMETHING","SOMETIMES","SOMEWHAT","SOMEWHERE","SON","SONG","SOON","SORRY","SORT","SOUND","SOURCE","SOUTH","SOUTHERN","SPACE","SPEAK","SPEAKER","SPECIAL","SPECIES","SPECIFIC","SPEECH","SPEED","SPEND","SPIRIT","SPORT","SPOT","SPREAD","SPRING","STAFF","STAGE","STAND","STANDARD","STAR","START","STATE","STATEMENT","STATION","STATUS","STAY","STEAL","STEP","STICK","STILL","STOCK","STONE","STOP","STORE","STORY","STRAIGHT","STRANGE","STRATEGY","STREET","STRENGTH","STRIKE","STRONG","STRONGLY","STRUCTURE","STUDENT","STUDIO","STUDY","STUFF","STYLE","SUBJECT","SUBSTANTIAL","SUCCEED","SUCCESS","SUCCESSFUL","SUCH","SUDDENLY","SUFFER","SUFFICIENT","SUGGEST","SUGGESTION","SUITABLE","SUM","SUMMER","SUN","SUPPLY","SUPPORT","SUPPOSE","SURE","SURELY","SURFACE","SURPRISE","SURROUND","SURVEY","SURVIVE","SWITCH","SYSTEM","TABLE","TAKE","TALK","TALL","TAPE","TARGET","TASK","TAX","TEA","TEACH","TEACHER","TEACHING","TEAM","TEAR","TECHNICAL","TECHNIQUE","TECHNOLOGY","TELEPHONE","TELEVISION","TELL","TEMPERATURE","TEND","TERM","TERMS","TERRIBLE","TEST","TEXT","THAN","THANK","THANKS","THAT","THE","THEATRE","THEIR","THEM","THEME","THEMSELVES","THEN","THEORY","THERE","THEREFORE","THESE","THEY","THIN","THING","THINK","THIS","THOSE","THOUGH","THOUGHT","THREAT","THREATEN","THROUGH","THROUGHOUT","THROW","THUS","TICKET","TIME","TINY","TITLE","TO","TODAY","TOGETHER","TOMORROW","TONE","TONIGHT","TOO","TOOL","TOOTH","TOP","TOTAL","TOTALLY","TOUCH","TOUR","TOWARDS","TOWN","TRACK","TRADE","TRADITION","TRADITIONAL","TRAFFIC","TRAIN","TRAINING","TRANSFER","TRANSPORT","TRAVEL","TREAT","TREATMENT","TREATY","TREE","TREND","TRIAL","TRIP","TROOP","TROUBLE","TRUE","TRUST","TRUTH","TRY","TURN","TWICE","TYPE","TYPICAL","UNABLE","UNDER","UNDERSTAND","UNDERSTANDING","UNDERTAKE","UNEMPLOYMENT","UNFORTUNATELY","UNION","UNIT","UNITED","UNIVERSITY","UNLESS","UNLIKELY","UNTIL","UP","UPON","UPPER","URBAN","US","USE","USED","USEFUL","USER","USUAL","USUALLY","VALUE","VARIATION","VARIETY","VARIOUS","VARY","VAST","VEHICLE","VERSION","VERY","VIA","VICTIM","VICTORY","VIDEO","VIEW","VILLAGE","VIOLENCE","VISION","VISIT","VISITOR","VITAL","VOICE","VOLUME","VOTE","WAGE","WAIT","WALK","WALL","WANT","WAR","WARM","WARN","WASH","WATCH","WATER","WAVE","WAY","WE","WEAK","WEAPON","WEAR","WEATHER","WEEK","WEEKEND","WEIGHT","WELCOME","WELFARE","WELL","WEST","WESTERN","WHAT","WHATEVER","WHEN","WHERE","WHEREAS","WHETHER","WHICH","WHILE","WHILST","WHITE","WHO","WHOLE","WHOM","WHOSE","WHY","WIDE","WIDELY","WIFE","WILD","WILL","WIN","WIND","WINDOW","WINE","WING","WINNER","WINTER","WISH","WITH","WITHDRAW","WITHIN","WITHOUT","WOMAN","WONDER","WONDERFUL","WOOD","WORD","WORK","WORKER","WORKING","WORKS","WORLD","WORRY","WORTH","WOULD","WRITE","WRITER","WRITING","WRONG","YARD","YEAH","YEAR","YES","YESTERDAY","YET","YOU","YOUNG","YOUR","YOURSELF","YOUTH" \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5ce8bcd..da7d171 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,7 @@ - mattrixwv.ProjectEuler.Driver + com.mattrixwv.project_euler.Driver diff --git a/src/main/java/com/mattrixwv/project_euler/Benchmark.java b/src/main/java/com/mattrixwv/project_euler/Benchmark.java index 1341fa4..aa4f246 100644 --- a/src/main/java/com/mattrixwv/project_euler/Benchmark.java +++ b/src/main/java/com/mattrixwv/project_euler/Benchmark.java @@ -189,6 +189,6 @@ public class Benchmark{ String timeResults = Stopwatch.getStr(totalTime); //Tally the results - return "%n%n" + problem.getResult() + "%nIt took an average of " + timeResults + " to run this problem through " + timesRun + " iterations%n%n"; + return "\n\n" + problem.getResult() + "\nIt took an average of " + timeResults + " to run this problem through " + timesRun + " iterations\n\n"; } } \ No newline at end of file diff --git a/src/main/java/com/mattrixwv/project_euler/ProblemSelection.java b/src/main/java/com/mattrixwv/project_euler/ProblemSelection.java index 48a2ea3..6e473af 100644 --- a/src/main/java/com/mattrixwv/project_euler/ProblemSelection.java +++ b/src/main/java/com/mattrixwv/project_euler/ProblemSelection.java @@ -38,7 +38,8 @@ public class ProblemSelection{ public static final List PROBLEM_NUMBERS = new ArrayList<>(Arrays.asList( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 67)); + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 67)); //Returns the problem corresponding to the given problem number public static Problem getProblem(Integer problemNumber){ @@ -82,6 +83,13 @@ public class ProblemSelection{ case 36 : problem = new Problem36(); break; case 37 : problem = new Problem37(); break; case 38 : problem = new Problem38(); break; + case 39 : problem = new Problem39(); break; + case 40 : problem = new Problem40(); break; + case 41 : problem = new Problem41(); break; + case 42 : problem = new Problem42(); break; + case 43 : problem = new Problem43(); break; + case 44 : problem = new Problem44(); break; + case 45 : problem = new Problem45(); break; case 67 : problem = new Problem67(); break; } return problem; diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem11.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem11.java index e2f6021..32af9e1 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem11.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem11.java @@ -211,7 +211,7 @@ public class Problem11 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("The greatest product of 4 numbers in a line is %d%nThe numbers are %s", ArrayAlgorithms.getProd(greatestProduct), greatestProduct.toString()); + return String.format("The greatest product of 4 numbers in a line is %d\nThe numbers are %s", ArrayAlgorithms.getProd(greatestProduct), greatestProduct.toString()); } //Returns the numbers that were being searched public List getNumbers(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem13.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem13.java index cbebea3..30ffc78 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem13.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem13.java @@ -292,7 +292,7 @@ public class Problem13 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("The sum of all %d numbers is %d%nThe first 10 digits of the sum of the numbers is %s", nums.size(), sum, (sum.toString()).substring(0, 10)); + return String.format("The sum of all %d numbers is %d\nThe first 10 digits of the sum of the numbers is %s", nums.size(), sum, (sum.toString()).substring(0, 10)); } //Returns the list of 50-digit numbers public List getNumbers(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem16.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem16.java index 671dcc5..15899f9 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem16.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem16.java @@ -85,7 +85,7 @@ public class Problem16 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("%d^%d = %s%nThe sum of the elements is %d", NUM_TO_POWER, POWER, num.toString(), sumOfElements); + return String.format("%d^%d = %s\nThe sum of the elements is %d", NUM_TO_POWER, POWER, num.toString(), sumOfElements); } //Returns the number that was calculated public BigInteger getNumber(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem20.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem20.java index 8e9a163..82ade4e 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem20.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem20.java @@ -86,7 +86,7 @@ public class Problem20 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("%d! = %s%nThe sum of the digits is: %d", TOP_NUM, num.toString(), sum); + return String.format("%d! = %s\nThe sum of the digits is: %d", TOP_NUM, num.toString(), sum); } //Returns the number 100! public BigInteger getNumber(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem21.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem21.java index aed8661..5ac1e8a 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem21.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem21.java @@ -117,9 +117,9 @@ public class Problem21 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - StringBuilder result = new StringBuilder(String.format("All amicable numbers less than %d are%n", LIMIT)); + StringBuilder result = new StringBuilder(String.format("All amicable numbers less than %d are\n", LIMIT)); for(int cnt = 0;cnt < amicable.size();++cnt){ - result.append(String.format("%d%n", amicable.get(cnt))); + result.append(String.format("%d\n", amicable.get(cnt))); } result.append(String.format("The sum of all of these amicable numbers is %d", ArrayAlgorithms.getSum(amicable))); diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem25.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem25.java index 069e7dd..cd822d4 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem25.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem25.java @@ -81,7 +81,7 @@ public class Problem25 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("The first Fibonacci number with %d digits is %s%nIts index is %d", NUM_DIGITS, number.toString(), index); + return String.format("The first Fibonacci number with %d digits is %s\nIts index is %d", NUM_DIGITS, number.toString(), index); } //Returns the Fibonacci number asked for public BigInteger getNumber(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem26.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem26.java index e17c2ae..f96be7a 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem26.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem26.java @@ -108,7 +108,7 @@ public class Problem26 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("The longest cycle is %d digits long%nIt started with the number %d", longestCycle, longestNumber); + return String.format("The longest cycle is %d digits long\nIt started with the number %d", longestCycle, longestNumber); } //Returns the length of the longest cycle public int getLongestCycle(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem27.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem27.java index 373b13b..12f4a29 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem27.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem27.java @@ -99,7 +99,7 @@ public class Problem27 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("The greatest number of primes found is %d%nIt was found with A = %d, B = %d%nThe product of A and B is %d", topN, topA, topB, topA * topB); + return String.format("The greatest number of primes found is %d\nIt was found with A = %d, B = %d\nThe product of A and B is %d", topN, topA, topB, topA * topB); } //Returns the top A that was generated public int getTopA(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem32.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem32.java index 0365d84..84c3179 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem32.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem32.java @@ -157,7 +157,7 @@ public class Problem32 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("There are %d unique 1-9 pandigitals%nThe sum of the products of these pandigitals is %d", listOfProducts.size(), sumOfPandigitals); + return String.format("There are %d unique 1-9 pandigitals\nThe sum of the products of these pandigitals is %d", listOfProducts.size(), sumOfPandigitals); } //Returns the sum of the pandigitals public long getSumOfPandigitals(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem39.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem39.java new file mode 100644 index 0000000..b4ee5f8 --- /dev/null +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem39.java @@ -0,0 +1,118 @@ +//ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem39.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//If p is the perimeter of a right triangle for which value of p <= 1000 is the number of solutions for the sides {a, b, c} maximized +//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/JavaClasses +/* + Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.project_euler.problems; + + +import java.util.ArrayList; +import java.util.List; + +import com.mattrixwv.Triple; + + +public class Problem39 extends Problem{ + //Variables + //Static variables + private static final long MAX_PERIMETER = 1000; + //Instace variables + private ArrayList> longestSolutions; + + //Functions + //Constructor + public Problem39(){ + super("If p is the perimeter of a right triangle for which value of p <= 1000 is the number of solutions for the sides {a, b, c} maximized"); + longestSolutions = new ArrayList<>(); + } + //Operational functions + private boolean isRightTriangle(long a, long b, long c){ + return (c * c) == ((a * a) + (b * b)); + } + //Solve the problem + public void solve(){ + //If the problem has already been solved do nothing and end the function + if(solved){ + return; + } + + //Start the timer + timer.start(); + + + //Loop for perimeter <= 1000 + for(long perimeter = 1;perimeter <= MAX_PERIMETER;++perimeter){ + ArrayList> solutions = new ArrayList<>(); + for(long a = 1;(a * 3) <= perimeter;++a){ + for(long b = a;(a + b + b) <= perimeter;++b){ + for(long c = b;(a + b + c) <= perimeter;++c){ + long sum = a + b + c; + if((isRightTriangle(a, b, c)) && (sum == perimeter)){ + solutions.add(new Triple<>(a, b, c)); + } + } + } + } + if(solutions.size() >= longestSolutions.size()){ + longestSolutions = solutions; + } + } + + + //Stop the timer + timer.stop(); + + //Throw a flag to show the problem is solved + solved = true; + } + //Reset the problem so it can be run again + @Override + public void reset(){ + super.reset(); + longestSolutions = new ArrayList<>(); + } + + //Gets + //Returns a string with the solution to the problem + public String getResult(){ + solvedCheck("results"); + return String.format("The perimeter with the largest number of solutions is %d", getLongestPerimeter()); + } + //Returns the array of solutions + public List> getLongestSolutions(){ + solvedCheck("array of solutions"); + return longestSolutions; + } + //Returns the perimeter of the solution + public long getLongestPerimeter(){ + solvedCheck("perimeter"); + long perimeter = 0; + if((longestSolutions != null) && (!longestSolutions.isEmpty())){ + Triple solution = longestSolutions.get(0); + perimeter = solution.getA() + solution.getB() + solution.getC(); + } + return perimeter; + } +} + +/* Results: +The perimeter with the largest number of solutions is 840 +It took an average of 6.564 seconds to run this problem through 100 iterations +*/ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem40.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem40.java new file mode 100644 index 0000000..569750f --- /dev/null +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem40.java @@ -0,0 +1,109 @@ +//ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem40.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//An irrational decimal fraction is created by concatenating the positive integers. Find the value of the following expression: d1 * d10 * d100 * d1000 * d10000 * d100000 * d1000000 +//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/JavaClasses +/* + Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.project_euler.problems; + + +import java.util.ArrayList; + +import com.mattrixwv.ArrayAlgorithms; + + +public class Problem40 extends Problem{ + //Variables + //Static variables + private static final long LARGEST_SUBSCRIPT = 1000000; + //Instance variables + private StringBuilder irrationalDecimal; + private long product; + + //Functions + //Constructor + public Problem40(){ + super("An irrational decimal fraction is created by concatenating the positive integers. Find the value of the following expression: d1 * d10 * d100 * d1000 * d10000 * d100000 * d1000000"); + irrationalDecimal = new StringBuilder(); + product = 0; + } + //Operational functions + //Solve the problem + public void solve(){ + //If the problem has already been solved do nothing and end the function + if(solved){ + return; + } + + //Start the timer + timer.start(); + + + //Add numbers to the string until it is long enough + for(Long num = 1L;irrationalDecimal.length() < LARGEST_SUBSCRIPT;++num){ + irrationalDecimal.append(num.toString()); + } + //Get integers from the string, multiply them, and save the value + ArrayList nums = new ArrayList<>(); + nums.add(Long.valueOf(Character.toString(irrationalDecimal.charAt(0)))); + nums.add(Long.valueOf(Character.toString(irrationalDecimal.charAt(9)))); + nums.add(Long.valueOf(Character.toString(irrationalDecimal.charAt(99)))); + nums.add(Long.valueOf(Character.toString(irrationalDecimal.charAt(999)))); + nums.add(Long.valueOf(Character.toString(irrationalDecimal.charAt(9999)))); + nums.add(Long.valueOf(Character.toString(irrationalDecimal.charAt(99999)))); + nums.add(Long.valueOf(Character.toString(irrationalDecimal.charAt(999999)))); + product = ArrayAlgorithms.getLongProd(nums); + + + //Stop the timer + timer.stop(); + + //Throw a flag to show the problem is solved + solved = true; + } + //Reset the problem so it can be run again + @Override + public void reset(){ + super.reset(); + irrationalDecimal = new StringBuilder(); + product = 0; + } + + //Gets + //Returns a string with the solution to the problem + public String getResult(){ + solvedCheck("results"); + return String.format("The product is %d", product); + } + //Returns the string of the decimal + public String irrationalDecimal(){ + solvedCheck("decimal string"); + return "0." + irrationalDecimal.toString(); + } + //Returns the product of the digits + public long getProduct(){ + solvedCheck("product"); + return product; + } +} + +/* Results: +The product is 210 +It took an average of 4.062 milliseconds to run this problem through 100 iterations +*/ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem41.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem41.java new file mode 100644 index 0000000..fbe9cea --- /dev/null +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem41.java @@ -0,0 +1,104 @@ +//ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem41.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//What is the largest n-digit pandigital prime? +//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/JavaClasses +/* + Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.project_euler.problems; + + +import java.util.ArrayList; + +import com.mattrixwv.NumberAlgorithms; +import com.mattrixwv.StringAlgorithms; + + +public class Problem41 extends Problem{ + //Variables + //Instance variables + private long largestPrimePandigital; + + //Functions + //Constructor + public Problem41(){ + super("What is the largest n-digit pandigital prime?"); + largestPrimePandigital = 0; + } + //Operational functions + //Solve the problem + public void solve(){ + //If the problem has already been solved do nothing and end the function + if(solved){ + return; + } + + //Start the timer + timer.start(); + + + //Get all of the possible numbers that could be pandigital + ArrayList perms = new ArrayList<>(); + perms.addAll(StringAlgorithms.getPermutations("1")); + perms.addAll(StringAlgorithms.getPermutations("12")); + perms.addAll(StringAlgorithms.getPermutations("123")); + perms.addAll(StringAlgorithms.getPermutations("1234")); + perms.addAll(StringAlgorithms.getPermutations("12345")); + perms.addAll(StringAlgorithms.getPermutations("123456")); + perms.addAll(StringAlgorithms.getPermutations("1234567")); + perms.addAll(StringAlgorithms.getPermutations("12345678")); + perms.addAll(StringAlgorithms.getPermutations("123456789")); + //Check if the numbers are prime + for(String perm : perms){ + long num = Long.parseLong(perm); + if((NumberAlgorithms.isPrime(num)) && (num > largestPrimePandigital)){ + largestPrimePandigital = num; + } + } + + + //Stop the timer + timer.stop(); + + //Throw a flag to show the problem is solved + solved = true; + } + //Reset the problem so it can be run again + @Override + public void reset(){ + super.reset(); + largestPrimePandigital = 0; + } + + //Gets + //Returns a string with the solution to the problem + public String getResult(){ + solvedCheck("results"); + return String.format("The largest n-digit pandigital prime is %d", largestPrimePandigital); + } + //Returns the largest prime pandigital + public long getLargestPrimePandigital(){ + solvedCheck("largest prime pandigital"); + return largestPrimePandigital; + } +} + +/* Results: +The largest n-digit pandigital prime is 7652413 +It took an average of 108.232 milliseconds to run this problem through 100 iterations +*/ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem42.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem42.java new file mode 100644 index 0000000..8092142 --- /dev/null +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem42.java @@ -0,0 +1,151 @@ +//ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem42.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//Triangular number t(n) = (n * (n + 1)) / 2. For A = 1, B = 2, ... find the number of triangular words in the file +//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/JavaClasses +/* + Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.project_euler.problems; + + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; + + +public class Problem42 extends Problem{ + //Variables + //Static variables + private static final String FILE_NAME = "files/Problem42Words.txt"; + private static final ArrayList fileWords = new ArrayList<>(); + //Instance variables + private ArrayList triangleWords; + + //Functions + //Constructor + public Problem42(){ + super("Triangular number t(n) - (n * (n + 1)) / 2. For A = 1, B = 2, ... find the number of trinagular words in the file"); + triangleWords = new ArrayList<>(); + } + //Operational function + //Read words from file into array + private void readFile(){ + if(!fileWords.isEmpty()){ + return; + } + File file = new File(FILE_NAME); + if(file.exists()){ + try{ + List lines = Files.readAllLines(file.toPath()); + for(String line : lines){ + String[] words = line.split(","); + for(String word : words){ + fileWords.add(word.replace("\"", "")); + } + } + } + catch(IOException error){ + throw new RuntimeException(error); + } + } + else{ + throw new RuntimeException("File not found"); + } + } + //Tet the sum of all letters in the string passed in + private long getValueFromWord(String word){ + long sum = 0; + for(char ch : word.toUpperCase().toCharArray()){ + long val = ch - 'A' + 1; + sum += val; + } + return sum; + } + //Check if the number passed in is a triangular number + private boolean isTriangularNumber(long num){ + long counter = 1; + long triangularNumber = 0; + while(triangularNumber < num){ + triangularNumber += counter++; + if(triangularNumber == num){ + return true; + } + } + return false; + } + //Solve the problem + public void solve(){ + //If the problem has already been solved do nothign and end the function + if(solved){ + return; + } + + //Start the timer + timer.start(); + + + //Read the file into the array + readFile(); + //Run through all elements in the array checking for triangular words + for(String word : fileWords){ + long value = getValueFromWord(word); + if(isTriangularNumber(value)){ + triangleWords.add(word); + } + } + + + //Stop the timer + timer.stop(); + + //Throw a flag to show the problem is solved + solved = true; + } + //Reset the problem so it can be run again + @Override + public void reset(){ + super.reset(); + triangleWords = new ArrayList<>(); + } + + //Gets + //Returns a string with the solution to the porblem + public String getResult(){ + solvedCheck("results"); + return String.format("The number of triangular numbers is %d", getNumberTriangularNumbers()); + } + //Returns the triangular words + public List getTriangularWords(){ + solvedCheck("triangular words"); + @SuppressWarnings("unchecked") + ArrayList clone = (ArrayList)triangleWords.clone(); + return clone; + } + //Returns the number of triangular words + public int getNumberTriangularNumbers(){ + solvedCheck("number of triangular words"); + return triangleWords.size(); + } +} + +/* Results: +The number of triangular numbers is 162 +It took an average of 166.881 microseconds to run this problem through 100 iterations +*/ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem43.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem43.java new file mode 100644 index 0000000..a842681 --- /dev/null +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem43.java @@ -0,0 +1,113 @@ +//ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem43.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//Find the sum of all 0-9 pandigital numbers with this property +//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/JavaClasses +/* + Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.project_euler.problems; + + +import java.util.ArrayList; +import java.util.List; + +import com.mattrixwv.ArrayAlgorithms; +import com.mattrixwv.NumberAlgorithms; +import com.mattrixwv.StringAlgorithms; + + +public class Problem43 extends Problem{ + //Variables + //Instance variables + private ArrayList subPrimePandigitals; + + //Functions + //Constructor + public Problem43(){ + super("Find the sum of all 0-9 pandigital numbers with this property"); + subPrimePandigitals = new ArrayList<>(); + } + //Operational functions + //Solve the problem + public void solve(){ + //If the porblem has already been solved do nothing and end the function + if(solved){ + return; + } + + //Start the timer + timer.start(); + + + //Get all of the 0-9 pandigitals + List pandigitals = StringAlgorithms.getPermutations("0123456789"); + //Get all of the primes we need + List primes = NumberAlgorithms.getNumPrimes(7L); + //Break them into their component parts and see if they are divisible by the prime numbers + for(String pandigital : pandigitals){ + boolean foundPrime = true; + for(int cnt = 3;cnt < pandigital.length();++cnt){ + String subNum = pandigital.substring(cnt - 2, cnt + 1); + long num = Long.parseLong(subNum); + if((num % primes.get(cnt - 3)) != 0){ + foundPrime = false; + break; + } + } + if(foundPrime){ + Long num = Long.parseLong(pandigital); + subPrimePandigitals.add(num); + } + } + + + //Stop the timer + timer.stop(); + + //Throw a flag to show the problem is solved + solved = true; + } + //Reset the problem so it can be run again + @Override + public void reset(){ + super.reset(); + subPrimePandigitals = new ArrayList<>(); + } + + //Gets + //Returns a string with the solution to the problem + public String getResult(){ + solvedCheck("results"); + return String.format("The sum of all pandigitals with the property is %d", getSumSubPrimePandigitals()); + } + //Returns the list of sub-prime Pandigitals + public List getSubPrimePandigitals(){ + solvedCheck("sub prime pandigitals"); + return subPrimePandigitals; + } + //Returns the sum of the list of sub-prime pandigitals + public long getSumSubPrimePandigitals(){ + solvedCheck("sum of sub prime pandigitals"); + return ArrayAlgorithms.getLongSum(subPrimePandigitals); + } +} + +/* Results: +The sum of all pandigitals with the property is 16695334890 +It took an average of 1.008 seconds to run this problem through 100 iterations +*/ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem44.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem44.java new file mode 100644 index 0000000..ac16957 --- /dev/null +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem44.java @@ -0,0 +1,119 @@ +//ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem44.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//Pentagonal number P = ((n * (3 * n - 1)) / 2). Find 2 pentagonal numbers whos sum and difference are also pentagonal numbers +//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/JavaClasses +/* + Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.project_euler.problems; + + +import java.util.ArrayList; +import java.util.List; + +import com.mattrixwv.generators.PentagonalNumberGenerator; + + +public class Problem44 extends Problem{ + //Variables + //Instance variables + private PentagonalNumberGenerator generator; + private List pentagonalList; + private long pentagonalNumber1; + private long pentagonalNumber2; + + //Functions + //Constructor + public Problem44(){ + super("Find 2 pentagonal numbers whos sum and difference are also pentagonal numbers"); + generator = new PentagonalNumberGenerator(); + pentagonalList = new ArrayList<>(); + pentagonalNumber1 = 0; + pentagonalNumber2 = 0; + } + //Operational functions + //Solve the porblem + public void solve(){ + //If the porblem has already been solved do nothing and end the function + if(solved){ + return; + } + + //Start the timer + timer.start(); + + + //Keep generating pentagonal numbers and checking if their sum and difference is also pentagonal + while(pentagonalNumber1 == 0){ + //Generate a new number and check it against every element we have already generated + Long newNum = generator.next(); + //Go through every number in the list and check if their sum and difference are pentagonal + for(Long num : pentagonalList){ + if(PentagonalNumberGenerator.isPentagonal(newNum + num) && PentagonalNumberGenerator.isPentagonal(newNum - num)){ + pentagonalNumber1 = num; + pentagonalNumber2 = newNum; + break; + } + } + pentagonalList.add(newNum); + } + + + //Stop the timer + timer.stop(); + + //Set a flag to show the porblem is solved + solved = true; + } + //Reset the porblem so it can be run again + @Override + public void reset(){ + super.reset(); + generator = new PentagonalNumberGenerator(); + pentagonalList = new ArrayList<>(); + pentagonalNumber1 = 0; + pentagonalNumber2 = 0; + } + + //Gets + //Returns a string with the solution to the problem + public String getResult(){ + solvedCheck("results"); + return String.format("The difference of the pentagonal numbers is %d", Math.abs(pentagonalNumber1 - pentagonalNumber2)); + } + //Returns the list of pentagaonl numbers + public List getPentagonalList(){ + solvedCheck("pentagonal list"); + return new ArrayList<>(pentagonalList); + } + //Returns the first pentagonal number + public long getPentagonalNumber1(){ + solvedCheck("first pentagonal number"); + return pentagonalNumber1; + } + //Returns the second pentagonal number + public long getPentagonalNumber2(){ + solvedCheck("second pentagonal number"); + return pentagonalNumber2; + } +} + +/* Results: +The difference of the pentagonal numbers is 5482660 +It took an average of 23.359 milliseconds to run this problem through 100 iterations +*/ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem45.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem45.java new file mode 100644 index 0000000..107bbec --- /dev/null +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem45.java @@ -0,0 +1,122 @@ +//ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem45.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//If p is the perimeter of a right triangle for which value of p <= 1000 is the number of solutions for the sides {a, b, c} maximized +//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/JavaClasses +/* + Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.project_euler.problems; + +import com.mattrixwv.generators.HexagonalNumberGenerator; +import com.mattrixwv.generators.PentagonalNumberGenerator; +import com.mattrixwv.generators.TriangularNumberGenerator; + +public class Problem45 extends Problem{ + //Variables + //Static variables + private static final long MIN_NUMBER = 40756; + //Instance variables + private long num; + private TriangularNumberGenerator triGen; + private PentagonalNumberGenerator penGen; + private HexagonalNumberGenerator hexGen; + + //Functions + //Constructor + public Problem45(){ + super("Find the next triangle number after 40755 that is also pentagonal and hexagonal"); + num = 0; + triGen = new TriangularNumberGenerator(); + penGen = new PentagonalNumberGenerator(); + hexGen = new HexagonalNumberGenerator(); + } + //Operational functions + //Solve the problem + public void solve(){ + //If the porblem has already been solved do nothing and end the function + if(solved){ + return; + } + + //Start the timer + timer.start(); + + //Generate the next number after MIN_NUMBER + long triNum = 0; + while(triNum < MIN_NUMBER){ + triNum = triGen.next(); + } + long penNum = 0; + while(penNum < MIN_NUMBER){ + penNum = penGen.next(); + } + long hexNum = 0; + while(hexNum < MIN_NUMBER){ + hexNum = hexGen.next(); + } + //Generate the next numbers until they all match + boolean matchFound = false; + while(!matchFound){ + hexNum = hexGen.next(); + while(penNum < hexNum){ + penNum = penGen.next(); + } + while(triNum < hexNum){ + triNum = triGen.next(); + } + + if((hexNum == penNum) && (hexNum == triNum)){ + num = hexNum; + matchFound = true; + } + } + + + //Stop the timer + timer.stop(); + + //Throw a flag to show the problem is solved + solved = true; + } + //Reset the porblem so it can be run again + @Override + public void reset(){ + super.reset(); + num = 0; + triGen = new TriangularNumberGenerator(); + penGen = new PentagonalNumberGenerator(); + hexGen = new HexagonalNumberGenerator(); + } + + //Gets + //Returns a string with the solution to the problem + public String getResult(){ + solvedCheck("results"); + return String.format("The next triangular/pentagonal/hexagonal number is %d", num); + } + //Returns the number + public long getNum(){ + solvedCheck("triangular/pentagonal/hexagonal number"); + return num; + } +} + +/* Results: +The next triangular/pentagonal/hexagonal number is 1533776805 +It took an average of 589.688 microseconds to run this problem through 100 iterations +*/ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem8.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem8.java index 61ed108..ab68ddb 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem8.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem8.java @@ -104,7 +104,7 @@ public class Problem8 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("The greatest product is %d%nThe numbers are %s", maxProduct, maxNums); + return String.format("The greatest product is %d\nThe numbers are %s", maxProduct, maxNums); } //Returns the string of numbers that produces the largest product public String getLargestNums(){ diff --git a/src/main/java/com/mattrixwv/project_euler/problems/Problem9.java b/src/main/java/com/mattrixwv/project_euler/problems/Problem9.java index c5392f2..d7e76ce 100644 --- a/src/main/java/com/mattrixwv/project_euler/problems/Problem9.java +++ b/src/main/java/com/mattrixwv/project_euler/problems/Problem9.java @@ -104,7 +104,7 @@ public class Problem9 extends Problem{ @Override public String getResult(){ solvedCheck("result"); - return String.format("The Pythagorean triplet is %d + %d + %d%nThe numbers' product is %d", a, b, Math.round(c), a * b * Math.round(c)); + return String.format("The Pythagorean triplet is %d + %d + %d\nThe numbers' product is %d", a, b, Math.round(c), a * b * Math.round(c)); } //Returns the length of the first side public int getSideA(){