Largest int from concatenated ints: Difference between revisions

m
added whitespace before the TOC, added other whitespace in the task's preamble, changed some wording in the task's preamble, added highlighting to a possible algorithm.
m (→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations, optimized inner DO loop.)
m (added whitespace before the TOC, added other whitespace in the task's preamble, changed some wording in the task's preamble, added highlighting to a possible algorithm.)
Line 1:
{{task}}
 
Given a set of positive integers, the task is to write a function to order the integers in such a way that the concatenation of the numbers forms the largest possible integer and return this integer.
;Task:
Given a set of positive integers, the task is to write a function to order the integers in such a way that the concatenation of the numbers forms the largest possible integer and return this integer.
 
Use the following two sets of integers as tests and show your program output here.
Line 6 ⟶ 8:
* {1, 34, 3, 98, 9, 76, 45, 4}
* {54, 546, 548, 60}
 
 
<br>
;Possible algorithms:
# A solution could be found by trying all combinations and return the best.
# Another way to solve this is to note that in the best arrangement, for any two adjacent original integers '''X''' and '''Y''', the concatenation '''X''' followed by '''Y''' will be numerically greater than or equal to the concatenation '''Y''' followed by '''X.
# Yet another way to solve this is to pad intsthe integers to the same size by repeating the digits then sort using these repeated intsintegers as a sort key.
 
 
<br>
;Cf:
* [http://www.quora.com/Algorithms/What-is-the-most-efficient-way-to-arrange-the-given-numbers-to-form-the-biggest-number Algorithms: What is the most efficient way to arrange the given numbers to form the biggest number?].
* [http://stackoverflow.com/questions/14532105/constructing-the-largest-number-possible-by-rearranging-a-list/14539943#14539943 Constructing the largest number possible by rearranging a list]
<br><br>
 
<br>
 
=={{header|Ada}}==