Ormiston pairs: Difference between revisions
Content added Content deleted
(Added C++ solution) |
|||
Line 367: | Line 367: | ||
382 Ormiston pairs before one million |
382 Ormiston pairs before one million |
||
3722 Ormiston pairs before ten million</pre> |
3722 Ormiston pairs before ten million</pre> |
||
=={{header|Python}}== |
|||
<syntaxhighlight lang="python">""" rosettacode.org task Ormiston_pairs """ |
|||
from sympy import primerange |
|||
PRIMES1M = list(primerange(1, 1_000_000)) |
|||
ASBASE10SORT = [str(sorted(list(str(i)))) for i in PRIMES1M] |
|||
ORMISTONS = [(PRIMES1M[i - 1], PRIMES1M[i]) for i in range(1, len(PRIMES1M)) |
|||
if ASBASE10SORT[i - 1] == ASBASE10SORT[i]] |
|||
print('First 30 Ormiston pairs:') |
|||
for (i, o) in enumerate(ORMISTONS): |
|||
if i < 30: |
|||
print(f'({o[0] : 6} {o[1] : 6} )', |
|||
end='\n' if (i + 1) % 5 == 0 else ' ') |
|||
else: |
|||
break |
|||
print(len(ORMISTONS), 'is the count of Ormiston pairs up to one million.') |
|||
</syntaxhighlight>{{out}} |
|||
<pre> |
|||
First 30 Ormiston pairs: |
|||
( 1913 1931 ) ( 18379 18397 ) ( 19013 19031 ) ( 25013 25031 ) ( 34613 34631 ) |
|||
( 35617 35671 ) ( 35879 35897 ) ( 36979 36997 ) ( 37379 37397 ) ( 37813 37831 ) |
|||
( 40013 40031 ) ( 40213 40231 ) ( 40639 40693 ) ( 45613 45631 ) ( 48091 48109 ) |
|||
( 49279 49297 ) ( 51613 51631 ) ( 55313 55331 ) ( 56179 56197 ) ( 56713 56731 ) |
|||
( 58613 58631 ) ( 63079 63097 ) ( 63179 63197 ) ( 64091 64109 ) ( 65479 65497 ) |
|||
( 66413 66431 ) ( 74779 74797 ) ( 75913 75931 ) ( 76213 76231 ) ( 76579 76597 ) |
|||
382 is the count of Ormiston pairs up to one million. |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |