mirror of
https://github.com/jlengrand/project_euler.git
synced 2026-03-10 08:41:20 +00:00
79 lines
5.9 KiB
Markdown
79 lines
5.9 KiB
Markdown
#My solutions to Project Euler 's website
|
||
|
||
[Project Euler](http://projecteuler.net/) is a website containing lots of problems aiming at being solved.
|
||
I play around with them in order to sharpen my algorithm skills.
|
||
|
||
This is always challenging to solve problems on paper and fantastic to come up with an algorithmic solution.
|
||
I use Python for its simplicity. Simple Python code is very similar to paper solution, and fast to implement.
|
||
|
||
Each script runs by itself and contains one of several functions that directly solve the function. Thus, running a script should give you the answer directly.
|
||
|
||
The script are named as e_problemnumber_inc. The higher the inc, the finer my solution.
|
||
|
||
Here is a list of all already solved problems, with a one line explanation.
|
||
Should be used in order to help future reuse of code :)
|
||
|
||
1 - Add all the natural numbers below one thousand that are multiples of 3 or 5. - 0.011 <br />
|
||
2 - By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. - 0.011 <br />
|
||
3 - Find the largest prime factor of a composite number. - < 1 sec <br />
|
||
4 - Find the largest palindrome made from the product of two 3-digit numbers. - 0.790 <br />
|
||
5 - What is the smallest number divisible by each of the numbers 1 to 20? - 4.102 <br />
|
||
6 - What is the difference between the sum of the squares and the square of the sums? - 0.013 <br />
|
||
7 - Find the 10001st prime. - too long <br />
|
||
8 - Discover the largest product of five consecutive digits in the 1000-digit number. - 0.045 <br />
|
||
9 - Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000. (a^2 + b^2 = c^2) - 1.500 <br />
|
||
10 - Calculate the sum of all the primes below two million. - too long <br />
|
||
11 - What is the greatest product of four adjacent numbers on the same straight line in the 20 by 20 grid? - 0.048 <br />
|
||
12 - What is the value of the first triangle number to have over five hundred divisors? - too long <br />
|
||
13 - Find the first ten digits of the sum of one-hundred 50-digit numbers. - 0.012 <br />
|
||
14 - Find the longest sequence using a starting number under one million. - too long <br />
|
||
15 - Starting in the top left corner in a 20 by 20 grid, how many routes are there to the bottom right corner? - 0.012 <br />
|
||
16 - What is the sum of the digits of the number 2^1000? - 0.012 <br />
|
||
17 - How many letters would be needed to write all the numbers in words from 1 to 1000? - 0.012 <br />
|
||
18 - Find the maximum sum travelling from the top of the triangle to the base. - 0.012 <br />
|
||
19 - How many Sundays fell on the first of the month during the twentieth century? - 0.088 <br />
|
||
20 - Find the sum of digits in 100! - 0.031 <br />
|
||
21 - Evaluate the sum of all amicable pairs under 10000. (d(a) = b, d(b) = a) - 9.100 <br />
|
||
22 - What is the total of all the name scores in the file of first names? - 0.082 <br />
|
||
23 - Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers. - _too long_ <br />
|
||
24 - What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? - too long <br />
|
||
25 - What is the first term in the Fibonacci sequence to contain 1000 digits? - 0.741 <br />
|
||
26 - Find the value of d < 1000 for which 1/d contains the longest recurring cycle. < 5 sec <br />
|
||
27 - Find a quadratic formula that produces the maximum number of primes for consecutive values of n. - too long <br />
|
||
28 - What is the sum of both diagonals in a 1001 by 1001 spiral? - < 1 sec <br />
|
||
29 - How many distinct terms are in the sequence generated by ab for 2 a 100 and 2 b 100? - < 1 sec <br />
|
||
30 - Find the sum of all the numbers that can be written as the sum of fifth powers of their digits. - < 3 sec <br />
|
||
31 - Investigating combinations of English currency denominations. - < 1 sec <br />
|
||
33 - Discover all the fractions with an unorthodox cancelling method. < 1 sec <br />
|
||
34 - Find the sum of all numbers which are equal to the sum of the factorial of their digits. - 30 sec - 16 sec <br />
|
||
35 - How many circular primes are there below one million? <br />
|
||
36 - Find the sum of all numbers less than one million, which are palindromic in base 10 and base 2. - 0.933 <br />
|
||
37 - Find the sum of all eleven primes that are both truncatable from left to right and right to left. < 1 min <br />
|
||
38 - What is the largest 1 to 9 pandigital that can be formed by multiplying a fixed number by 1, 2, 3, ... ? < 1 sec <br />
|
||
39 - If p is the perimeter of a right angle triangle, {a, b, c}, which value, for p <= 1000, has the most solutions? - 1min<br />
|
||
41 - What is the largest n-digit pandigital prime that exists? < 5 min <br />
|
||
42 - Using words.txt, a 16K text file containing nearly two-thousand common English words, how many are triangle words? - < 1 sec <br />
|
||
45 - Find the next triangle number that is also pentagonal and hexagonal. - < 1 sec <br />
|
||
46 - What is the smallest odd composite that cannot be written as the sum of a prime and twice a square? - < 6 sec <br />
|
||
48 - Find the last ten digits of 1^1 + 2^2 + ... + 1000^1000. - 0.053 <br />
|
||
52 - Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. - 2min <br />
|
||
53 - How many values of C(n,r), for 1 <= n <= 100, exceed one-million? - < 1 sec <br />
|
||
67 - Using an efficient algorithm find the maximal sum in the triangle? - 0.027 <br />
|
||
|
||
**In progress: **
|
||
|
||
43 - Find the sum of all pandigital numbers with an unusual sub-string divisibility property. <br />
|
||
47 - Find the first four consecutive integers to have four distinct primes factors. <br />
|
||
97 - Find the last ten digits of the non-Mersenne prime: 28433 × 2^7830457 + 1. <br />
|
||
|
||
**WARNING : Spoil inside for those who want to solve problems by themselves :)**
|
||
|
||
## Contact
|
||
|
||
I would enjoy having feedback if you try to solve euler's problems too :).
|
||
Feel free to mail me for any comment or request.
|
||
|
||
You can contact me at julien at lengrand dot fr, or on my [current website](http://www.lengrand.fr)
|
||
|
||
Last update : 5/6/2012
|