Given a array of single digit number, work out if any 2 of them add up to 10 and print them out
(). as there is only one 5
((5,5),(5,5)) as there is odd number of 5s and each 5 can be used only once
Here are the rules!
- Assume input will only be an unsorted array of positive single digit integers
- each number will be pair up only once, which means if there are three 5s it only form 1 pair (5,5). If there are (3,3,7) it will only form 1 pair (3,7)
- For the input: You can use any type of parentheses(or lack of) as long as readers can tell that the input is a single array of numbers.
- For the output: It must look like an array of pairs. Where the array is the same form as your input.(If you did not use any parenheses in your input, you have to use some kind of symbols so that any readers can tell they are pairs in an array)
(1,2,3,4,5,5,6,7) =((4,6),(5,5),(3,7)) (1,2,3,4,5) = () (5,5,5,5,5) = ((5,5),(5,5)) (1,2,3,3,4,5,6,7)=((3,7),(4,6)) (9,8,7,6,4,4,3,1)=((9,1),(7,3),(6,4))
shorter an answer is, the better!
Edit1: update the rules and Testcases from comments
Edit2: update rules to define format of input.
Edit2: update rules to define format of output. trying to be as accommodating as possible.