29
3
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.
How are strings that contain quote marks represented in the input? – feersum – 2016-02-05T11:23:20.327
@feersum Wouldn't that depend on your language? – Martin Ender – 2016-02-05T11:25:34.590
@feersum With escape characters probably, but if the language doesn't handle that, that's okay. – Adnan – 2016-02-05T11:25:35.520
@MartinBüttner If input is taken from stdin, it should not depend on what language is used. – feersum – 2016-02-05T13:31:03.147
3@feersum That's new to me. Even from STDIN
[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. – Martin Ender – 2016-02-05T13:33:17.933