Magic numbers: Difference between revisions
→{{header|jq}}: def extend:
(→{{header|jq}}: def extend:) |
|||
Line 175:
The solution presented here depends on the unbounded-precision integer
arithmetic of the Go implementations of jq
can be generated by an invocation of the form:
<pre>
</pre>
<syntaxhighlight lang=jq>
def sum(s): reduce s as $x (0; .+$x);
# Emit all the polydivisibles in the form of an array of arrays
# such that the numbers in .[i] are the polydivisibles of length i+1
def polydivisible:
def extend($n):
# input: an array of arrays, such that the numbers in .[i] are the polydivisibles of length i+1
def
|
| if $x|length ==
else $in +
[[range(1;10)]] | extend;
▲ | .new = []
def pandigital:
tostring | gsub("0";"") | explode | unique | length == 9;
# Select the pandigitals from .
# Input:
# Output: an array
def pd($k):
.
def tasks:
| .
| "There are \(sum(.
"\nThe largest is \(.
"\nThere are:",
(range(0;
| "\(.
( "\nAll magic numbers that are pan-digital in 1 through 9 with no repeats: ", pd(8)[] ),
( "\nAll magic numbers that are pan-digital in 0 through 9 with no repeats: ", pd(9)[] ) ;
Line 258 ⟶ 259:
3816547290
</pre>
=={{header|Phix}}==
|