Awesome
Project Euler Solutions
About Project Euler
Project Euler is a website to challenge mathematicians and programmers with mathematical problems intended to help you to improve your mathematical and programming skills.
Extracted from Wikipedia:
Project Euler (named after Leonhard Euler) is a website dedicated to a series of computational problems intended to be solved with computer programs. The project attracts adults and students interested in mathematics and computer programming. It includes over 400 problems, with a new one added every weekend. Problems are of varying difficulty but each is solvable in less than a minute using an efficient algorithm on a modestly powered computer.
About this repository
This is my attempt to solve some problems of this project, using the python language. The target is to solve as many as I can, and keep the time consumed by each script below 30 second at a minimum and preferably below 10s.
Contents:
-
directories from
$ ls -d [0-9][0-9][0-9]
: contains the python script(s) with the solution and the auxiliary files needed to solve them. Sometimes I have more than one solution to the same problem. -
README.md
: this document -
times.json
: the time taken to solve each script stored in json format -
update.py
: an utility script to automatize some tasks:-
Downloads an off-line copy of the Project Euler's website with all the problems in a single page.
-
Creates this document automatically, computing the solved problems to know the time consumed by each solution.
-
Creates a new dir locally for each problem (new problems also), downloads automatically all the necessary auxiliary files and create a new python file with the problem's formulation as the document string.
-
This is an example of a created python file for this script:
#!/usr/bin/env python2
# -*- coding: utf8 -*-
"""
Special Pythagorean triplet
Problem 9
http://projecteuler.net/problem=9
A Pythagorean triplet is a set of three natural numbers, a < b < c, for
which, a² + b² = c²
For example, 3² + 4² = 9 + 16 = 25 = 5².
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
About Cheating
Don't cheat! If you cheat, you only fool yourself! If you can't do it, you can not do it, that's all! Almost you tried, and if you keep learning and studying, maybe one day you can solve those problems that seemed so hard a few early.
Be proud of what you have achieved instead, even if is little. Especially if your math skills or education is not so vast (as in my case). I'm very proud to have solved all of this problems without cheating or copy another else's solutions. That's the right attitude.
But, once you have a solution, you can learn a lot from the solutions of others. That's the purpose of the Project Euler's forum and it's fine. That's the main purpose of this repository too. Maybe you couldn't learn a lot from my solutions, maybe even you can laugh of the most naive ones, but doesn't matter, be humble and remember that even the most idiot can teach you always something. The second purpose is to have a online backup of this code, some problems were hard to break and I would hate to loose this code.
The most important thing isn't the Project Euler's rank that you achieve or the number of problems that you solved, the most important thing is what you have learned in the process!
Solved Problems
Times computed in a Intel Core i7-3770 CPU @ 3.40GHz processor.
Solved 68 out of 427 problems
Problem 001
001.py 0.022554s ✓
001_1.py 0.014849s ✓
Problem 002
002.py 0.023146s ✓
002_1.py 0.021222s ✓
Problem 003
003.py 0.021620s ✓
003_1.py 0.020232s ✓
003_2.py 0.028219s ✓
Problem 004
004.py 0.249954s ✓
004_1.py 0.023268s ✓
Problem 005
005.py 5.808191s ✓
005_1.py 0.025107s ✓
Problem 006
006.py 0.021474s ✓
006_1.py 0.020441s ✓
Problem 007
007.py 0.261622s ✓
007_1.py 0.208496s ✓
Problem 008
008.py 0.023076s ✓
008_1.py 0.021203s ✓
Problem 009
009.py 0.017036s ✓
Problem 010
010.py 11.039828s ⚠
010_1.py 0.850945s ✓
Problem 011
011.py 0.028042s ✓
Problem 012
012.py 9.322057s ✓
012_1.py 8.749063s ✓
Problem 013
013.py 0.023989s ✓
Problem 014
014.py 24.668415s ⚠
014_1.py 2.676699s ✓
Problem 015
015.py 0.025735s ✓
Problem 016
016.py 0.028405s ✓
Problem 017
017.py 0.025587s ✓
Problem 018
018.py 0.020194s ✓
Problem 019
019.py 0.027074s ✓
Problem 020
020.py 0.017099s ✓
Problem 021
021.py 0.158187s ✓
Problem 022
022.py 0.199019s ✓
Problem 023
023.py 0.833783s ✓
Problem 024
024.py 0.672126s ✓
Problem 025
025.py 0.045723s ✓
Problem 026
026.py 0.273532s ✓
Problem 027
027.py 3.228487s ✓
027_1.py 1.219820s ✓
Problem 028
028.py 0.024141s ✓
Problem 029
029.py 0.035167s ✓
Problem 030
030.py 1.203444s ✓
Problem 032
032.py 4.573121s ✓
032_1.py 1.037601s ✓
Problem 033
033.py 0.042764s ✓
Problem 034
034.py 9.126602s ✓
034_1.py 2.713816s ✓
034_2.py 6.083059s ✓
Problem 035
035.py 7.120787s ✓
Problem 036
036.py 0.576948s ✓
Problem 037
037.py 0.514927s ✓
Problem 038
038.py 0.062644s ✓
Problem 039
039.py 0.565841s ✓
Problem 040
040.py 0.203063s ✓
Problem 041
041.py 0.730648s ✓
Problem 042
042.py 0.023286s ✓
Problem 043
043.py 16.914430s ⚠
043_1.py 12.292378s ⚠
Problem 044
044.py 0.849638s ✓
Problem 045
045.py 0.067391s ✓
Problem 046
046.py 0.133557s ✓
Problem 047
047.py 44.992091s ✕
047_1.py 8.543741s ✓
047_2.py 8.752145s ✓
047_3.py 0.116513s ✓
Problem 048
048.py 0.032231s ✓
Problem 049
049.py 0.029477s ✓
Problem 050
050.py 13.950840s ⚠
Problem 051
051.py 0.886498s ✓
Problem 052
052.py 0.153540s ✓
Problem 053
053.py 0.052489s ✓
Problem 054
054.py 0.080987s ✓
Problem 055
055.py 0.078629s ✓
Problem 056
056.py 0.306206s ✓
Problem 057
057_1.py 0.026501s ✓
057_2.py 0.021239s ✓
Problem 058
058.py 28.746523s ⚠
058_1.py 6.593587s ✓
Problem 059
059.py 2.733520s ✓
Problem 061
061.py 0.292618s ✓
Problem 062
062.py 0.067345s ✓
Problem 063
063.py 0.028142s ✓
Problem 067
067.py 0.030304s ✓
Problem 069
069.py 0.020157s ✓
Problem 079
079.py 0.023037s ✓
Problem 081
081.py 0.036246s ✓
Problem 092
092.py 0.021010s ✓
Problem 097
097.py 0.059794s ✓
Problem 099
099.py 0.020839s ✓