Erdős–Woods numbers: Difference between revisions

m
syntax highlighting fixup automation
(added Raku programming solution)
m (syntax highlighting fixup automation)
Line 33:
=={{header|Julia}}==
{{trans|Python}}
<langsyntaxhighlight lang="julia">""" modified from https://codegolf.stackexchange.com/questions/230509/find-the-erd%C5%91s-woods-origin/ """
 
using BitIntegers
Line 106:
 
test_erdős_woods()
</langsyntaxhighlight>{{out}} Same as Wren example.
 
=={{header|Phix}}==
Line 112:
{{trans|Julia}}
Using flag arrays instead of bigint bitfields
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<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>
<!--</langsyntaxhighlight>-->
{{out}}Same as Wren example.
 
=={{header|Python}}==
Original author credit to the Stackexchange website user ovs, who in turn credits user xash.
<langsyntaxhighlight lang="python">""" modified from https://codegolf.stackexchange.com/questions/230509/find-the-erd%C5%91s-woods-origin/ """
 
def erdős_woods(n):
Line 274:
COUNT += 1
K += 1
</langsyntaxhighlight>{{out}}Same as Wren example.
 
=={{header|Raku}}==
{{trans|Wren}}
{{trans|Julia}}
<syntaxhighlight lang="raku" perl6line># 20220308 Raku programming solution
 
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 } }</langsyntaxhighlight>
{{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.
<langsyntaxhighlight lang="ecmascript">import "./big" for BigInt
import "./fmt" for Conv, Fmt
import "./sort" for Sort
Line 445:
}
k = k + 1
}</langsyntaxhighlight>
 
{{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!
<langsyntaxhighlight lang="ecmascript">import "./gmp" for Mpz
import "./fmt" for Conv, Fmt
import "./sort" for Sort
Line 566:
}
k = k + 1
}</langsyntaxhighlight>
 
{{out}}
10,327

edits