# Project Euler Solutions

## Project Euler — Problem 59 Solution

Prob­lem Each char­ac­ter on a com­put­er is assigned a unique code and the pre­ferred stan­dard is ASCII (Amer­i­can Stan­dard Code for Infor­ma­tion Inter­change). For exam­ple, upper­case A = 65, aster­isk (*) = 42, and low­er­case k = 107. A mod­ern encryp­tion method is to take a text file, con­vert the bytes to ASCII, then XOR …

## Project Euler — Problem 79 Solution

Prob­lem A com­mon secu­ri­ty method used for online bank­ing is to ask the user for three ran­dom char­ac­ters from a pass­code. For exam­ple, if the pass­code was 531278, they may ask for the 2nd, 3rd, and 5th char­ac­ters; the expect­ed reply would be: 317. The text file, keylog.txt, con­tains fifty suc­cess­ful login attempts. Giv­en that …

## Project Euler — Problem 145 Solution

Prob­lem Some pos­i­tive inte­gers n have the prop­er­ty that the sum [ n + reverse(n) ] con­sists entire­ly of odd (dec­i­mal) dig­its. For instance, 36 + 63 = 99 and 409 + 904 = 1313. We will call such num­ber­sre­versible; so 36, 63, 409, and 904 are reversible. Lead­ing zeroes are not allowed in either …

## Project Euler — Problem 74 Solution

Prob­lem The num­ber 145 is well known for the prop­er­ty that the sum of the fac­to­r­i­al of its dig­its is equal to 145: 1! + 4! + 5! = 1 + 24 + 120 = 145 Per­haps less well known is 169, in that it pro­duces the longest chain of num­bers that link back to …

## Project Euler — Problem 205 Solution

Prob­lem Peter has nine four-sided (pyra­mi­dal) dice, each with faces num­bered 1, 2, 3, 4. Col­in has six six-sided (cubic) dice, each with faces num­bered 1, 2, 3, 4, 5, 6. Peter and Col­in roll their dice and com­pare totals: the high­est total wins. The result is a draw if the totals are equal. What …

## Project Euler — Problem 85

Prob­lem By count­ing care­ful­ly it can be seen that a rec­tan­gu­lar grid mea­sur­ing 3 by 2 con­tains eigh­teen rec­tan­gles: Although there exists no rec­tan­gu­lar grid that con­tains exact­ly two mil­lion rec­tan­gles, find the area of the grid with the near­est solu­tion. Solu­tion This prob­lem looks more dif­fi­cult than it is, I’m not going to go …

## Project Euler — Problem 81 Solution

Prob­lem In the 5 by 5 matrix below, the min­i­mal path sum from the top left to the bot­tom right, by only mov­ing to the right and down, is indi­cat­ed in bold red and is equal to 2427. Find the min­i­mal path sum, in matrix.txt (right click and ‘Save Link/Target As…’), a 31K text file …

## Project Euler — Problem 99 Solution

Prob­lem Com­par­ing two num­bers writ­ten in index form like 211 and 37 is not dif­fi­cult, as any cal­cu­la­tor would con­firm that 211 = 2048 < 37 = 2187. How­ev­er, con­firm­ing that 632382518061 > 519432525806 would be much more dif­fi­cult, as both num­bers con­tain over three mil­lion dig­its. Using base_exp.txt (right click and ‘Save Link/Target As…’), …

## Project Euler — Problem 54 Solution

Prob­lem In the card game pok­er, a hand con­sists of five cards and are ranked, from low­est to high­est, in the fol­low­ing way: High Card: High­est val­ue card. One Pair: Two cards of the same val­ue. Two Pairs: Two dif­fer­ent pairs. Three of a Kind: Three cards of the same val­ue. Straight: All cards are …

## Project Euler — Problem 89 Solution

Prob­lem The rules for writ­ing Roman numer­als allow for many ways of writ­ing each num­ber (see FAQ:Roman Numer­als). How­ev­er, there is always a “best” way of writ­ing a par­tic­u­lar num­ber. For exam­ple, the fol­low­ing rep­re­sent all of the legit­i­mate ways of writ­ing the num­ber six­teen: IIIIIIIIIIIIIIII VIIIIIIIIIII VVIIIIII XIIIIII VVVI XVI The last exam­ple being …