A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Thor running an experiment with the first 50 problems in Project Euler. Experiment: how does prototyping a solution in a dynamically typed language (Python) then translating to a statically typed language (Rust) affect my efficiency (and vice versa)? Methodology: `shuf -i 0-1 -n1`, heads (1) we start in Rust, tails (0) in Python. Start a timer, and record time to develop the solution in each language Possibly confounding: (1) Thor is more knowledgeable at Rust than Python, and expects to gain relatively more Pythonic skill over time. | |||||||||||||||||||||||||||
2 | Problem | date | solved in | rust (mins) | python (mins) | TOTAL (mins) | runtime r (ms) | runtime p (ms) | notes | time: solve | time: translate | time: rust solve | time: python solve | time: rust from python | time: python from rust | |||||||||||||
3 | 1 | 9/2/2021 | p | 1.8 | 3.1 | 4.9 | 0.008 | 0.036 | 238163 | 3.1 | 1.8 | 3.1 | 1.8 | |||||||||||||||
4 | 2 | 9/2/2021 | r | 4.7 | 2.7 | 7.4 | 0.0008 | 0.047 | 4.7 | 2.7 | 4.7 | 2.7 | ||||||||||||||||
5 | 3 | 9/2/2021 | p | 6.2 | 5.7 | 11.9 | 0.019 | 1.12 | some time spent fighting type checks | 5.7 | 6.2 | 5.7 | 6.2 | |||||||||||||||
6 | 4 | 9/2/2021 | p | 4.7 | 7.2 | 11.9 | 379 | 98.3 | woah. What's eating my rust solution cycles? | 7.2 | 4.7 | 7.2 | 4.7 | |||||||||||||||
7 | 5 | 9/2/2021 | r | 2 | 0.8 | 2.8 | 0.00087 | 0.029 | 232792560 | 2 | 0.8 | 2 | 0.8 | |||||||||||||||
8 | 6 | 9/2/2021 | p | 3.4 | 12 | 15.4 | 0.0053 | 0.047 | had to look up python string substitution and fiddle with lambda | 12 | 3.4 | 12 | 3.4 | |||||||||||||||
9 | 7 | 9/2/2021 | p | 3.2 | 15.6 | 18.8 | 857 | 1848 | sorta slow runtimes. in review, i could have implemented the sieve more efficiently. | 15.6 | 3.2 | 15.6 | 3.2 | |||||||||||||||
10 | 8 | 9/2/2021 | p | 19.7 | 47 | 66.7 | 1.05 | 21.5 | struggled with opening a file in python, converting elements in a list from strings to ints in both. Feeling a bit out of practice. | 47 | 19.7 | 47 | 19.7 | |||||||||||||||
11 | 9 | 9/7/2021 | r | 4.8 | 4.6 | 9.4 | 3166 | 7445 | Starting to run into time efficiency problems | 4.8 | 4.6 | 4.8 | 4.6 | |||||||||||||||
12 | 10 | 9/7/2021 | p | 16.4 | 32 | 48.4 | 61651 | 87348 | This algorithm ran pretty grossly slow. I should find a better way. | 32 | 16.4 | 32 | 16.4 | |||||||||||||||
13 | 11 | 9/10/2021 | p | 24.7 | 54.4 | 79.1 | 0.188 | 0.926 | Half the python time was spent debugging, ultimately discovering a transposed line. Only half my time spent debugging? I must be doing great! | 54.4 | 24.7 | 54.4 | 24.7 | |||||||||||||||
14 | 12 | 9/10/2021 | r | 35.5 | 34.2 | 69.7 | 106 | 1389 | Rust: About 12 minutes to derive a multiplicity theorem, another 12 to write a solution, and a final 12 to debug my solution. Python: mostly trying to figure out how to use python dictionaries, and fiddling with the (totally lame) reduce function before eventually finding a way to use accumulators. | 35.5 | 34.2 | 35.5 | 34.2 | |||||||||||||||
15 | 13 | 9/10/2021 | r | 14.9 | 10.2 | 25.1 | 0.319 | 0.324 | Rust: a bit of fiddling with strings. This would be a good problem to review whether I'm using string types efficiently. Python: I could benefit from knowing how to get an array from a map. | 14.9 | 10.2 | 14.9 | 10.2 | |||||||||||||||
16 | 14 | 9/10/2021 | r | 57.9 | 14.4 | 72.3 | 3770 | 1086 | Rust: Oh man. Debugging imperative programs is a bitch. Starting to remember why functional programming became a thing. Interestingly, my caching strategy doesn't appear to make any difference in performance. Python: Why was this soln faster to run than my rust soln? | 57.9 | 14.4 | 57.9 | 14.4 | |||||||||||||||
17 | 15 | 9/13/2021 | r | 4.8 | 3.2 | 8 | 0.005 | 0.064 | basic combinatorics | 4.8 | 3.2 | 4.8 | 3.2 | |||||||||||||||
18 | 16 | 9/13/2021 | p | 19.5 | 1.8 | 21.3 | 0.076 | 0.145 | Rust: futzing with bigint crates (num::bigint is a lie), then converting a char to a digit. Python: haha amortized big int type go brrr | 1.8 | 19.5 | 1.8 | 19.5 | |||||||||||||||
19 | 17 | 9/13/2021 | r | 47.5 | 22.5 | 70 | 0.87 | 2.5 | Looots of time figuring out where my off by ones were (screw english), looking around until finding I miscounted the number of letters in 40 and 80, when I should have just spelled em out and let the program count for me. Starting to ask myself, how can I implement such that I spend the least possible time debugging. Especially tedious detail problems like this one. | 47.5 | 22.5 | 47.5 | 22.5 | |||||||||||||||
20 | 18 | 9/14/2021 | r | 158 | 29.5 | 187.5 | 0.338 | 0.849 | Apparently I'm pretty rusty (eh) at recursion. Took over an hour on the first try, but I was running in the wrong direction. Started again from scratch on a second try, trying to be a bit more thoughtful. This was the hardest problem for me so far, by about 2x, and I'm sure there were more elegant ways to implement. Even just translating my solution from rust to python took an half an hour, even without much debugging to do. This one is one to review. | Removed as outlier | ||||||||||||||||||
21 | 19 | 9/15/2021 | r | 2.7 | 1 | 3.7 | 0.005 | 0.04 | uniformly distributed sundays, not uniformly distributed amount to complete problems | 2.7 | 1 | 2.7 | 1 | |||||||||||||||
22 | 20 | 9/15/2021 | r | 12.6 | 5.8 | 18.4 | 0.49 | 0.14 | Bigints to make life easy | 12.6 | 5.8 | 12.6 | 5.8 | |||||||||||||||
23 | 21 | 9/15/2021 | r | 29.4 | 31.4 | 60.8 | 930 | 2361 | Rust: reasonably easy problem, with a couple of lazy implementation choices. Python: figuring out how to use some functional tools | 29.4 | 31.4 | 29.4 | 31.4 | |||||||||||||||
24 | 22 | 9/16/2021 | p | 20.4 | 17.7 | 38.1 | 16 | 17 | Both: reasonably straightforward, just cleaning up fiddly details | 17.7 | 20.4 | 17.7 | 20.4 | |||||||||||||||
25 | 23 | 9/16/2021 | p | 19 | 75.3 | 94.3 | 511 | 1490 | First tried to use a slow factoring and filtering algorithm, was too slow, thought of a better iterative strategy | 75.3 | 19 | 75.3 | 19 | |||||||||||||||
26 | 24 | 9/16/2021 | r | 47.3 | 9.1 | 56.4 | 982 | 461 | Screwed around with implementing my own permutation algorithm before using a library method | 47.3 | 9.1 | 47.3 | 9.1 | |||||||||||||||
27 | 25 | 9/17/2021 | p | 12.8 | 6 | 18.8 | 309 | 27 | Bigints and laugh | 6 | 12.8 | 6 | 12.8 | |||||||||||||||
28 | 26 | 9/20/2021 | r | 189 | 23 | 212 | 118 | 209 | The euler gods swore karmic punishment for my getting too used to bigints being the natural solution. | Removed as outlier | ||||||||||||||||||
29 | 27 | 9/21/2021 | r | 54.5 | 18.3 | 72.8 | 419 | 725 | Reasonably straightforward, still using a lazy prime algorithm | 54.5 | 18.3 | 54.5 | 18.3 | |||||||||||||||
30 | 28 | 9/21/2021 | r | 85 | 45 | 130 | 96 | 394 | Turns out, a million values is too many for a recursive algorithm in Rust. makes me a lil sad. ran into a weird python quirk about creating 2d arrays | 85 | 45 | 85 | 45 | |||||||||||||||
31 | 29 | 9/21/2021 | r | 17.5 | 3 | 20.5 | 92 | 4 | Easy street compared to the last couple, I may be getting better though | 17.5 | 3 | 17.5 | 3 | |||||||||||||||
32 | 30 | 9/21/2021 | p | 5.1 | 10.2 | 15.3 | 1267 | 1909 | Another straight forward implementation | 10.2 | 5.1 | 10.2 | 5.1 | |||||||||||||||
33 | 31 | 9/22/2021 | p | 8 | 20 | 28 | 1663 | 9408 | Surprised this recursive algorithm took so long | 20 | 8 | 20 | 8 | |||||||||||||||
34 | 32 | 9/22/2021 | r | 49.2 | 22 | 71.2 | 328 | 53 | Surprisingly many edge cases in my algorithm | 49.2 | 22 | 49.2 | 22 | |||||||||||||||
35 | 33 | 9/23/2021 | r | 69 | 20.7 | 89.7 | 34 | 9 | Played around with generics in Rust for funsies, was inefficient ofc; otherwise not that complex | 69 | 20.7 | 69 | 20.7 | |||||||||||||||
36 | 34 | 9/23/2021 | r | 17.8 | 5.3 | 23.1 | 5700 | 4200 | Probably much slower if I recalculate the factorials everytime | 17.8 | 5.3 | 17.8 | 5.3 | |||||||||||||||
37 | 35 | 9/23/2021 | p | 25 | 16.4 | 41.4 | 403 | 636 | Straightforward to develop a python algorithm | 16.4 | 25 | 16.4 | 25 | |||||||||||||||
38 | 36 | 9/23/2021 | r | 19.5 | 4.8 | 24.3 | 1270 | 374 | Python makes that very easy | 19.5 | 4.8 | 19.5 | 4.8 | |||||||||||||||
39 | 37 | 9/23/2021 | r | 49 | 26 | 75 | 204 | 466 | Primes! More primes! | 49 | 26 | 49 | 26 | |||||||||||||||
40 | 38 | 9/23/2021 | p | 13 | 13.7 | 26.7 | 285 | 27 | I must be getting better at pythoning | 13.7 | 13 | 13.7 | 13 | |||||||||||||||
41 | 39 | 9/24/2021 | p | 12 | 12.1 | 24.1 | 1700 | 14300 | Starting to feel repetitively easy | 12.1 | 12 | 12.1 | 12 | |||||||||||||||
42 | 40 | 9/24/2021 | r | 17 | 5.1 | 22.1 | 107 | 189 | Wheeeeeeeeee | 17 | 5.1 | 17 | 5.1 | |||||||||||||||
43 | 41 | 9/24/2021 | r | 19 | 4.2 | 23.2 | 456 | 6672 | Primes and pandigitals | 19 | 4.2 | 19 | 4.2 | |||||||||||||||
44 | 42 | 9/24/2021 | p | 7.9 | 9.5 | 17.4 | 2.2 | 2.6 | Haven't opened a file in awhile | 9.5 | 7.9 | 9.5 | 7.9 | |||||||||||||||
45 | 43 | 9/24/2021 | p | 18 | 16.8 | 34.8 | 3700 | 9196 | Filter n stuff | 16.8 | 18 | 16.8 | 18 | |||||||||||||||
46 | 44 | 9/24/2021 | p | 12 | 51.5 | 63.5 | 5833 | 780 | Hardest one in a while, Review this one! | 51.5 | 12 | 51.5 | 12 | |||||||||||||||
47 | 45 | 9/25/2021 | r | 19.6 | 4.5 | 24.1 | 30 | 400 | 19.6 | 4.5 | 19.6 | 4.5 | ||||||||||||||||
48 | 46 | 9/25/2021 | r | 34.6 | 7.1 | 41.7 | 13 | 39 | Took a longer route than possibly necessary, review | 34.6 | 7.1 | 34.6 | 7.1 | |||||||||||||||
49 | 47 | 10/8/2021 | p | 7.4 | 20.9 | 28.3 | 793 | 31629 | Could have used a prime sive to expedite algorithm, instead of lazy factoring algorithm. | 20.9 | 7.4 | 20.9 | 7.4 | |||||||||||||||
50 | 48 | 10/8/2021 | r | 12 | 2.2 | 14.2 | 6 | 17 | Darn easy | 12 | 2.2 | 12 | 2.2 | |||||||||||||||
51 | 49 | 10/8/2021 | r | 21.5 | 6.9 | 28.4 | 518 | 182 | Took a little time to figure out how to check permutations, settled on a slightly incorrect algorithm | 21.5 | 6.9 | 21.5 | 6.9 | |||||||||||||||
52 | 50 | 10/8/2021 | p | 15.7 | 43.2 | 58.9 | 174 | 3200 | about half time spent debugging | 43.2 | 15.7 | 43.2 | 15.7 | |||||||||||||||
53 | tot hours: | 37.2 | AVERAGES: | 25.9 | 12.3 | 28.8 | 22.4 | 12.5 | 12.1 | |||||||||||||||||||
54 | AVERAGE: first 25 | 23.3 | 12.1 | 22.0 | 24.7 | 12.6 | 11.7 | |||||||||||||||||||||
55 | AVERAGE: 10-25 | 30.9 | 16.6 | 28.1 | 37.3 | 20.9 | 14.6 | |||||||||||||||||||||
56 | AVERAGE: last 25 | 28.2 | 12.5 | 34.7 | 20.0 | 12.4 | 12.5 | |||||||||||||||||||||
57 | Results: | It takes about 1.5x as long to develop a rust solution than a python solution | ||||||||||||||||||||||||||
58 | Translating a solution takes about 12.5 minutes on average, in either direction | |||||||||||||||||||||||||||
59 | Problems that would take 35 minutes or more to solve in Rust have a plausible speedup if first solved in python then translated (20m solve +13m translate) | |||||||||||||||||||||||||||
60 | I disincluded the two outliers where I started in Rust and failed to efficiently develop a solution. | |||||||||||||||||||||||||||
61 | ||||||||||||||||||||||||||||
62 | ||||||||||||||||||||||||||||
63 | ||||||||||||||||||||||||||||
64 | ||||||||||||||||||||||||||||
65 | ||||||||||||||||||||||||||||
66 | ||||||||||||||||||||||||||||
67 | ||||||||||||||||||||||||||||
68 | ||||||||||||||||||||||||||||
69 | ||||||||||||||||||||||||||||
70 | ||||||||||||||||||||||||||||
71 | ||||||||||||||||||||||||||||
72 | ||||||||||||||||||||||||||||
73 | ||||||||||||||||||||||||||||
74 | ||||||||||||||||||||||||||||
75 | ||||||||||||||||||||||||||||
76 | ||||||||||||||||||||||||||||
77 | ||||||||||||||||||||||||||||
78 | ||||||||||||||||||||||||||||
79 | ||||||||||||||||||||||||||||
80 | ||||||||||||||||||||||||||||
81 | ||||||||||||||||||||||||||||
82 | ||||||||||||||||||||||||||||
83 | ||||||||||||||||||||||||||||
84 | ||||||||||||||||||||||||||||
85 | ||||||||||||||||||||||||||||
86 | ||||||||||||||||||||||||||||
87 | ||||||||||||||||||||||||||||
88 | ||||||||||||||||||||||||||||
89 | ||||||||||||||||||||||||||||
90 | ||||||||||||||||||||||||||||
91 | ||||||||||||||||||||||||||||
92 | ||||||||||||||||||||||||||||
93 | ||||||||||||||||||||||||||||
94 | ||||||||||||||||||||||||||||
95 | ||||||||||||||||||||||||||||
96 | ||||||||||||||||||||||||||||
97 | ||||||||||||||||||||||||||||
98 | ||||||||||||||||||||||||||||
99 | ||||||||||||||||||||||||||||
100 |