Erdős–Woods numbers: Difference between revisions
m
syntax highlighting fixup automation
(added Raku programming solution) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 33:
=={{header|Julia}}==
{{trans|Python}}
<
using BitIntegers
Line 106:
test_erdős_woods()
</
=={{header|Phix}}==
Line 112:
{{trans|Julia}}
Using flag arrays instead of bigint bitfields
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> <span style="color: #000080;font-style:italic;">-- takes about 47s (of blank screen) though, also note the line
-- below which triggered an unexpected violation on desktop/Phix
Line 207:
<span style="color: #000000;">k</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<!--</
{{out}}Same as Wren example.
=={{header|Python}}==
Original author credit to the Stackexchange website user ovs, who in turn credits user xash.
<
def erdős_woods(n):
Line 274:
COUNT += 1
K += 1
</
=={{header|Raku}}==
{{trans|Wren}}
{{trans|Julia}}
<syntaxhighlight lang="raku"
sub invmod($n, $modulo) { # rosettacode.org/wiki/Modular_inverse#Raku
Line 343:
say "The first 20 Erdős–Woods numbers and their minimum interval start values are:";
for (16..116) { if (my $ew = ew $_) > 0 { printf "%3d -> %d\n",$_,$ew } }</
{{out}}Same as Wren example.
Line 355:
I ended up translating the Python 3.8 code (the more readable version) [https://codegolf.stackexchange.com/questions/230509/find-the-erd%C5%91s-woods-origin here], 6th post down, and found the first 20 E-W numbers in around 93 seconds. Much slower than Python which has arbitrary precision numerics built-in nowadays but acceptable for Wren.
<
import "./fmt" for Conv, Fmt
import "./sort" for Sort
Line 445:
}
k = k + 1
}</
{{out}}
Line 475:
{{libheader|Wren-gmp}}
Takes about 15.4 seconds which is significantly faster than Wren-cli, but still nowhere near as fast as the Python version - a majestic 1.2 seconds!
<
import "./fmt" for Conv, Fmt
import "./sort" for Sort
Line 566:
}
k = k + 1
}</
{{out}}
|