3 ms·
I was about to observation that the python code as posted in the blog missed an important optimization, reordering some of the tests to: for b in range(1,
by randomstring 10y ago
I was about to observation that the python code as posted in the blog missed an important optimization, reordering some of the tests to:
for b in range(1, 27)
for n in range(1, 27)
if b**3 + z**3 + n**3 + o**9 == 1997
for k in (3,4)
for e in range(1, 27)
This reduces the number of innermost tests and on my laptop it runs about 18x faster than the blog's solution. That was:
for k in (3,4)
for b in range(1, 27)
for e in range(1, 27)
for n in range(1, 27)
if b**3 + z**3 + n**3 + o**9 == 1997
Then I see that @eutectic did the same optimization in his Haskell code. Nice!