The Task
The task is very simple. Given an array containing only integers and strings, output the largest number and the smallest number.
Test Cases
Input: [1, 2, 3, 4, 5, 6, 7, 8]
Output: 1, 8
Input: [5, 4, 2, 9, 1, 10, 5]
Output: 1, 10
Input: [7, 8, 10, "Hello", 5, 5]
Output: 5, 10
Numbers in strings are not considered integers:
Input: [1, 2, 3, 4, "5"]
Output: 1, 4
If there is only one integer, it is both the largest and smallest integer:
Input: [1]
Output: 1, 1
Input: ["1", "2", "3", "4", 5]
Output: 5, 5
Rules
- You can assume that an array will always contains at least one integer.
- All integers are positive (greater than 0)
- The order of the output doesn't matter.
- This is code-golf, so the submission with the least amount of bytes wins!
- Strings can contain all printable ASCII characters (
32 - 126
) and are non-empty.
[1, 2, 3]
1 2 3
and{1; 2; 3}
are all valid input formats, so I don't see why it should be any different for string literals received from STDIN. \$\endgroup\$