+ 3
CHALLENGE // ARRAY AND SUM
The objective is: You receive an array (e.g. 1, 2, 7) and you have to make a code that finds out if any of this numbers together makes a total of 9. You should always sum ONLY 2 numbers. Print the pair of numbers. e.g. In the array 1, 2, 7: 2 + 7 = 9 The array may not be sorted ;) and you cannot sort it! e.g. 7, 1, 2 I will give you 24h ;) the best answer wins
6 Réponses
+ 9
(Python) ⭐
https://code.sololearn.com/cnEQ77a0JAR9/?ref=app
Updated to receive array from input.
Also removed duplicated pairs.
+ 2
In ruby
https://code.sololearn.com/cj2AkTKu9GnQ
Update:
"the array should be introduced as an input"
you should've mentioned that earlier. We're not the three eyed raven.
I've updated my code. give your input space separated, like 1 2 3 4 5
0
They are both nice, but the array should be introduced as an input ;) so which person can test a diferent array
0
Here you go. Let's you input the size of the array and checks for valid numerical input for the size.
https://code.sololearn.com/cnUMkUpYugKk/?ref=app
- 1
here is mine
you can input integers as well as floating points SEPERATED BY SPACE
example--> 1 8 1.1 7.9
output--> 1+8=9
1.1+7.9=9
https://code.sololearn.com/cBPqHI4Ip3vr/?ref=app