Anonymous user
Next highest int from digits: Difference between revisions
m
→{{header|REXX}}: simplified code for inner DO loop.
m (→{{header|REXX}}: added commas to the numbers in the output.) |
m (→{{header|REXX}}: simplified code for inner DO loop.) |
||
Line 282:
parse arg n /*obtain optional arguments from the CL*/
if n='' | n="," then n= 0 9 12 21 12453 738440 45072010 95322020 /*use the defaults? */
w= length( commas( word(n, words(n) ) ) )
do j=1 for words(n); y= word(n, j)
masky= mask(y) /*build a digit mask for a supplied int*/
lim= copies(9, length(y) ) /*construct a LIMIT for the DO loop. */
▲ end /*#*/
if #>lim then #= 0 /*if # > lim, then there is no valid #*/
Line 302 ⟶ 300:
/*──────────────────────────────────────────────────────────────────────────────────────*/
mask: parse arg z, $; @.= 0 /* [↓] build an unsorted digit mask. */
do k=1 for length(z); parse var z _ +1 z; @._= @._ + 1
end /*k*/
do m=0 for 10; if @.m==0 then iterate; $= $ || copies(m, @.m)
end /*m*/; return $ /* [↑] build a sorted digit mask.*/</lang>
|