Anaprimes: Difference between revisions

Content added Content deleted
(Added Wren)
(→‎{{header|Wren}}: Now uses an insertion sort rather than the built-in quicksort. About 9% quicker than before.)
Line 191: Line 191:
=={{header|Wren}}==
=={{header|Wren}}==
{{libheader|Wren-math}}
{{libheader|Wren-math}}
{{libheader|Wren-sort}}
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
Unsurprisingly, getting up to 1 billion is a struggle for the Wren interpreter - 9 minutes 43 seconds on my Core i7 machine.
Unsurprisingly, getting up to 1 billion is a struggle for the Wren interpreter - 8 minutes 50 seconds on my Core i7 machine.
I gave up after that.
I gave up after that.
<syntaxhighlight lang="ecmascript">import "./math" for Int
<syntaxhighlight lang="ecmascript">import "./math" for Int
import "./sort" for Sort
import "./fmt" for Fmt
import "./fmt" for Fmt


Line 202: Line 204:
var anaprimes = {}
var anaprimes = {}
for (p in primes) {
for (p in primes) {
var d = Int.digits(p).sort().join()
var d = Sort.insertion(Int.digits(p)).join()
if (anaprimes.containsKey(d)) {
if (anaprimes.containsKey(d)) {
anaprimes[d].add(p)
anaprimes[d].add(p)