Anonymous user
Largest int from concatenated ints: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, changed indentations, optimized inner DO loop.
(→ES5) |
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations, optimized inner DO loop.) |
||
Line 1,636:
if _>digits() then numeric digits _ /*use enough decimal digits for maximum*/
/* [↓] examine each number in the list*/
do while z\=='';
big=isOK( word(z, 1) );
/* [↓] check the rest of the integers.*/
do k=2 to words(z); #=isOK(word(z,k)) /*obtain an an integer from the list. */
L=max(
if left(#, L, left(#, 1) ) <<= left(big, L, left(big, 1) ) then iterate
big=#; index=k /*we found a new biggie (and the index)*/
end /*k*/ /* [↑] find max concatenated integer. */
Line 1,655:
isOK: parse arg ?; if datatype(?,'W') then return abs(?)/1 /*normalize the integer.*/
say; say '***error*** number ' ? "isn't an integer."; say; exit 13</lang>
'''output''' when using the default (internal) integer lists:
<pre>
998764543431 max for: {1, 34, 3, 98, 9, 76, 45, 4}
|