This problem is from Five programming problems every Software Engineer should be able to solve in less than 1 hour which itself is an interesting read. The first few problems are trivial, but the fourth one can be a bit more interesting.
Given a list of integers separated by a single space on standard input, print out the largest and smallest values that can be obtained by concatenating the integers together on their own line.
5 56 50
Various points of order:
- The order of the results are smallest then largest.
- Only the smallest and largest values may be printed out (iterating over all the variations and printing them out isn't valid).
- There will always be two or more integers in the list.
- It is possible for the largest and smallest results to be the same. In the case of input
5 55, the number
555should be printed twice.
- The integers are not necessarily distinct.
5 5is valid input.
0s on integers are not valid input. You will not need to account for
As this is code golf, shortest entry wins.