Largest int from concatenated ints: Difference between revisions

m
→‎{{header|REXX}}: changed for format of the first two REXXes lists, added verbiage to the output.
m (→‎exponentiated integers: added wording to the version section header.)
m (→‎{{header|REXX}}: changed for format of the first two REXXes lists, added verbiage to the output.)
Line 1,954:
===simple integers===
<lang rexx>/*REXX program constructs the largest integer from an integer list using concatenation.*/
@.=.; @.1 = '{1, 34, 3, 98, 9, 76, 45, 4}' /*the 1st integer list to be used. */
@.2 = '{54, 546, 548, 60}' /* " 2nd " " " " " */
@.3 = '{ 4, 45, 54, 5}' /* " 3rd " " " " " */
w=0 /* [↓] process all the integer lists.*/
do j=1 while @.j\==.; $ z= space(@.j) /*keep truckin' until lists exhausted. */
zw=spacemax( translate(@.jw, , '])},{length(['z) ); $= /*performobtain scrubbingmaximum onwidth theto integeralign listoutput.*/
do dowhile kz\=2''; to words(z)idx=1; #big=norm(k1) /*obtainkeep an a number fromexamining the list. until done.*/
w=max(w, length( @.j) ) /*obtain maximum width to align output.*/
do while z\do k='';2 idx=1to words(z); big #=norm(1k) /*keepobtain examiningan a number from the list. until done.*/
do k=2 to words(z); #=norm(k) /*obtain an a number from the list. */
L=max(length(big), length(#) ) /*get the maximum length of the integer*/
if left(#, L, left(#, 1) ) <<= left(big, L, left(big, 1) ) then iterate
Line 1,970 ⟶ 1,969:
$=$ || big /*append " " " ───► $. */
end /*while z*/ /* [↑] process all integers in a list.*/
say 'maxlargest for:concatenatated integer from ' left( space(@.j), w) " is ─────► " $ /*show the maximum integer and the list*/
end end /*j*/ /* [↑] process each list of integers. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
norm: arg i; #=word(z, i); er=' ***error*** '; /*extract anumeric numberdigits from300 the (Z)/*get # listfrom Z. */
if \datatype(#,'W') then do; say er 'number' # "isn't an integer."; exit 13; end
return #/1 /*it's an integer, then normalize it. */</lang>
{{out|output|text=&nbsp; when using the default (internal) integer lists:}}
<pre>
maxlargest for:concatenatated integer from {1, 34, 3, 98, 9, 76, 45, 4} is ─────► 998764543431
maxlargest for:concatenatated integer from {54, 546, 548, 60} is is─────► 6054854654
maxlargest for:concatenatated integer from { 4, 45, 54, 5} is ─────► 554454
</pre>
 
Line 1,994 ⟶ 1,993:
<br>digits, &nbsp; but displaying the result would be problematic for results wider than the display area).
<lang rexx>/*REXX program constructs the largest integer from an integer list using concatenation.*/
@.=.; @.1 = '{1, 34, 3, 98, 9, 76, 45, 4}' /*the 1st integer list to be used. */
@.2 = '{54, 546, 548, 60}' /* " 2nd " " " " " */
@.3 = '{ 4, 45, 54, 5}' /* " 3rd " " " " " */
@.4 = '{ 4, 45, 54, 5, 6.6e77 }' /* " 4th " " " " " */
w=0 /* [↓] process all the integer lists.*/
do j=1 while @.j\==.; $z= space(@.j) /*keep truckin' until lists exhausted. */
zw=spacemax( translate(@.jw, , '])},{length(['z) ); $= /*performobtain scrubbingmaximum onwidth theto integeralign listoutput.*/
w=max(w, length( @.j) ) /*obtain maximum width to align output.*/
do while z\=''; idx=1; big=norm(1) /*keep examining the list until done.*/
do k=2 to words(z); #=norm(k) /*obtain an a number from the list. */
Line 2,011 ⟶ 2,009:
$=$ || big /*append " " " ───► $. */
end /*while z*/ /* [↑] process all integers in a list.*/
say 'maxlargest for:concatenatated integer from ' left( space(@.j), w) " is " " $is /*show" the maximum integer and the list*/$
end end /*j*/ /* [↑] process each list of integers. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
norm: arg i; #=word(z, i); er=' ***error*** '; /*extract anumeric numberdigits from300 the (Z)/*get # listfrom Z. */
if \datatype(#,'N') then do; say er 'number' # "isn't an number."; exit 13; end
else #= abs(#) / 1 /*a #, so normalize it*/
Line 2,025 ⟶ 2,023:
{{out|output|text=&nbsp; when using the default (internal) integer lists:}}
<pre>
maxlargest for:concatenatated integer from {1, 34, 3, 98, 9, 76, 45, 4} is 998764543431
maxlargest for:concatenatated integer from {54, 546, 548, 60} is 6054854654
maxlargest for:concatenatated integer from { 4, 45, 54, 5} is 554454
maxlargest for:concatenatated integer from { 4, 45, 54, 5, 6.6e77 } is 660000000000000000000000000000000000000000000000000000000000000000000000000000554454
</pre>