Solutions for Project Euler
These are my solutions for Project Euler problems. I've listed many languages in the About section on the right. However, I can barely code in Python and absolutely nothing in any other language at this moment, since I've started coding about 2 months ago. Hence, that's more like a wishlist than an actual description, at least for now.
All code in this repo is runnable, and gives you a comparison of the execution times of each implementation (overall execution times of each implementation for the predetermined number of iterations, as well as min/avg/max of single run). It is tested whether the solution provides a correct answer for the given variable, but may produce an error on different variable. I'm planning to add more testing.
Main files on each folder (e.g. main.py) will run every function implemented on every problems I've solved so far. By default, each problem takes about a second to finish the entire iterations on my computer, so it'll take about a couple of minutes to run if I ever write the solutions for every problems. Right now, it takes 10 seconds.
Languages | Progress |
---|---|
Python | 30 / 747 |
C | 0 / 747 |
C++ | 0 / 747 |
C# | 0 / 747 |
F# | 0 / 747 |
Go | 0 / 747 |
Haskell | 0 / 747 |
Java | 0 / 747 |
JavaScript | 0 / 747 |
PHP | 0 / 747 |
Ruby | 0 / 747 |
SQL | 0 / 747 |
This section hasn't been fully implemented yet. This is my attempt to compare the crunching speed of each language, but there are many limitations. The first and foremost limitation would be: each implementation of each language may use slightly different algorithms (or substantially different one in some cases), due to various reasons, including the differences in features, data types, or styles of each language, my own limited capability, et cetera. Also, each language may have a varying degree of optimization. As such, this is more like the comparison between apple and orange, rather than apple to apple comparison.
This table shows how much nanoseconds it took for the fastest algo to complete one iteration on average. I haven't implemented the auto-update feature yet (except for Python), but once implemented, running main files on each folder (e.g. main.py) will trigger the automatic update of this table.
Problems | py | pypy | c | cpp | cs | fs | go | hs | java | js | php | rb | sql |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 581 | 25 | 982 | ||||||||||
2 | 2,160 | 131 | |||||||||||
3 | 314,980 | 5,755 | |||||||||||
4 | 521,115 | 46,393 | |||||||||||
5 | 50,807 | 17,003 | |||||||||||
6 | 220 | 35 | |||||||||||
7 | 9,436μs | 1,311μs | |||||||||||
8 | 1,406μs | 165,874 | |||||||||||
9 | 19,685μs | 61,736 | |||||||||||
10 | 163,380μs | 33,435μs | |||||||||||
11 | 801,136 | 103,612 | |||||||||||
12 | 155,919μs | 30,274μs | |||||||||||
13 | 1,935 | 2,570 | |||||||||||
14 | 777,981μs | 407,915μs | |||||||||||
15 | 1,702 | 404 | |||||||||||
16 | 23,152 | 13,352 | |||||||||||
17 | 1,472μs | 584,939 | |||||||||||
18 | 38,705 | 21,386 | |||||||||||
19 | 145,267 | 5,966 | |||||||||||
20 | 12,553 | 7,740 | |||||||||||
21 | 92,111μs | 117,632μs | |||||||||||
22 | 3,092μs | 2,909μs | |||||||||||
23 | 1,111ms | 604,644μs | |||||||||||
24 | 13,230μs | 27,619μs | |||||||||||
25 | 22,750μs | 88,062μs | |||||||||||
26 | 14,905μs | 5,679μs | |||||||||||
27 | 40,082μs | 4,081μs | |||||||||||
28 | 239,247 | 7,370 | |||||||||||
29 | 4,068μs | 8,549μs | |||||||||||
30 | 716,723μs | 67,669μs |
- The table above is auto-generated from the following environments;
- py: Python 3.9.5.final.0 (64 bit), macOS 11.4 (arm64), Apple M1
- pypy: PyPy 7.3.5 with GCC Apple LLVM 12.0.5 (clang-1205.0.22.9), macOS 11.4 (x86_64), Apple M1
- rb: Ruby 3.0.1p64, Windows 10 Professional (AMD64), Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
This table shows how much iterations it computes for about a second.
Problems | py | pypy | c | cpp | cs | fs | go | hs | java | js | php | rb | sql |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 65,000 | 600,000 | 4,000 | ||||||||||
2 | 150,000 | 1,000,000 | |||||||||||
3 | 1,500 | 26,000 | |||||||||||
4 | 420 | 2,200 | |||||||||||
5 | 20,000 | 60,000 | |||||||||||
6 | 44,000 | 1,500,000 | |||||||||||
7 | 110 | 780 | |||||||||||
8 | 700 | 7,000 | |||||||||||
9 | 50 | 17,000 | |||||||||||
10 | 6 | 32 | |||||||||||
11 | 1,250 | 9,500 | |||||||||||
12 | 7 | 31 | |||||||||||
13 | 25,000 | 10,000 | |||||||||||
14 | 2 | 3 | |||||||||||
15 | 560,000 | 2,300,000 | |||||||||||
16 | 43,000 | 80,000 | |||||||||||
17 | 680 | 1,650 | |||||||||||
18 | 26,000 | 27,000 | |||||||||||
19 | 3,200 | 31,000 | |||||||||||
20 | 34,000 | 65,000 | |||||||||||
21 | 11 | 10 | |||||||||||
22 | 320 | 350 | |||||||||||
23 | 1 | 2 | |||||||||||
24 | 77 | 35 | |||||||||||
25 | 45 | 11 | |||||||||||
26 | 12 | 6 | |||||||||||
27 | 25 | 240 | |||||||||||
28 | 4,500 | 130,000 | |||||||||||
29 | 250 | 125 | |||||||||||
30 | 2 | 14 |
- Each main script not just runs the fastest algo, but runs every implementations. Thus, doing poorly on some algo could hamper the result greatly, even if the language is pretty fast on most implementations.