ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
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)
notestime: solvetime: translatetime: rust solve
time: python solve
time: rust from python
time: python from rust
3
19/2/2021p1.83.14.90.0080.0362381633.11.83.11.8
4
29/2/2021r4.72.77.40.00080.0474.72.74.72.7
5
39/2/2021p6.25.711.90.0191.12
some time spent fighting type checks
5.76.25.76.2
6
49/2/2021p4.77.211.937998.3
woah. What's eating my rust solution cycles?
7.24.77.24.7
7
59/2/2021r20.82.80.000870.02923279256020.820.8
8
69/2/2021p3.41215.40.00530.047
had to look up python string substitution and fiddle with lambda
123.4123.4
9
79/2/2021p3.215.618.88571848
sorta slow runtimes. in review, i could have implemented the sieve more efficiently.
15.63.215.63.2
10
89/2/2021p19.74766.71.0521.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.
4719.74719.7
11
99/7/2021r4.84.69.431667445
Starting to run into time efficiency problems
4.84.64.84.6
12
109/7/2021p16.43248.46165187348
This algorithm ran pretty grossly slow. I should find a better way.
3216.43216.4
13
119/10/2021p24.754.479.10.1880.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.424.754.424.7
14
129/10/2021r35.534.269.71061389
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.534.235.534.2
15
139/10/2021r14.910.225.10.3190.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.910.214.910.2
16
149/10/2021r57.914.472.337701086
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.914.457.914.4
17
159/13/2021r4.83.280.0050.064basic combinatorics4.83.24.83.2
18
169/13/2021p19.51.821.30.0760.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.819.51.819.5
19
179/13/2021r47.522.5700.872.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.522.547.522.5
20
189/14/2021r15829.5187.50.3380.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
199/15/2021r2.713.70.0050.04
uniformly distributed sundays, not uniformly distributed amount to complete problems
2.712.71
22
209/15/2021r12.65.818.40.490.14Bigints to make life easy12.65.812.65.8
23
219/15/2021r29.431.460.89302361
Rust: reasonably easy problem, with a couple of lazy implementation choices. Python: figuring out how to use some functional tools
29.431.429.431.4
24
229/16/2021p20.417.738.11617
Both: reasonably straightforward, just cleaning up fiddly details
17.720.417.720.4
25
239/16/2021p1975.394.35111490
First tried to use a slow factoring and filtering algorithm, was too slow, thought of a better iterative strategy
75.31975.319
26
249/16/2021r47.39.156.4982461
Screwed around with implementing my own permutation algorithm before using a library method
47.39.147.39.1
27
259/17/2021p12.8618.830927Bigints and laugh612.8612.8
28
269/20/2021r18923212118209
The euler gods swore karmic punishment for my getting too used to bigints being the natural solution.
Removed as outlier
29
279/21/2021r54.518.372.8419725
Reasonably straightforward, still using a lazy prime algorithm
54.518.354.518.3
30
289/21/2021r854513096394
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
85458545
31
299/21/2021r17.5320.5924
Easy street compared to the last couple, I may be getting better though
17.5317.53
32
309/21/2021p5.110.215.312671909
Another straight forward implementation
10.25.110.25.1
33
319/22/2021p8202816639408
Surprised this recursive algorithm took so long
208208
34
329/22/2021r49.22271.232853
Surprisingly many edge cases in my algorithm
49.22249.222
35
339/23/2021r6920.789.7349
Played around with generics in Rust for funsies, was inefficient ofc; otherwise not that complex
6920.76920.7
36
349/23/2021r17.85.323.157004200
Probably much slower if I recalculate the factorials everytime
17.85.317.85.3
37
359/23/2021p2516.441.4403636
Straightforward to develop a python algorithm
16.42516.425
38
369/23/2021r19.54.824.31270374Python makes that very easy19.54.819.54.8
39
379/23/2021r492675204466Primes! More primes! 49264926
40
389/23/2021p1313.726.728527
I must be getting better at pythoning
13.71313.713
41
399/24/2021p1212.124.1170014300
Starting to feel repetitively easy
12.11212.112
42
409/24/2021r175.122.1107189Wheeeeeeeeee 175.1175.1
43
419/24/2021r194.223.24566672Primes and pandigitals194.2194.2
44
429/24/2021p7.99.517.42.22.6Haven't opened a file in awhile9.57.99.57.9
45
439/24/2021p1816.834.837009196Filter n stuff16.81816.818
46
449/24/2021p1251.563.55833780
Hardest one in a while, Review this one!
51.51251.512
47
459/25/2021r19.64.524.13040019.64.519.64.5
48
469/25/2021r34.67.141.71339
Took a longer route than possibly necessary, review
34.67.134.67.1
49
4710/8/2021p7.420.928.379331629
Could have used a prime sive to expedite algorithm, instead of lazy factoring algorithm.
20.97.420.97.4
50
4810/8/2021r122.214.2617Darn easy122.2122.2
51
4910/8/2021r21.56.928.4518182
Took a little time to figure out how to check permutations, settled on a slightly incorrect algorithm
21.56.921.56.9
52
5010/8/2021p15.743.258.91743200
about half time spent debugging
43.215.743.215.7
53
tot hours:
37.2AVERAGES:25.912.328.822.412.512.1
54
AVERAGE: first 2523.312.122.024.712.611.7
55
AVERAGE: 10-2530.916.628.137.320.914.6
56
AVERAGE: last 2528.212.534.720.012.412.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