CHALLENGE // ARRAY AND SUM | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

14th Aug 2017, 10:43 PM
André Oliveira
André Oliveira - avatar
6 Answers
+ 9
(Python) ⭐ https://code.sololearn.com/cnEQ77a0JAR9/?ref=app Updated to receive array from input. Also removed duplicated pairs.
15th Aug 2017, 1:11 AM
MIZO PRO (ハムザ)
MIZO PRO (ハムザ) - avatar
15th Aug 2017, 11:06 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 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
14th Aug 2017, 11:02 PM
Salekin
Salekin - avatar
0
They are both nice, but the array should be introduced as an input ;) so which person can test a diferent array
15th Aug 2017, 7:12 AM
André Oliveira
André Oliveira - avatar
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
15th Aug 2017, 7:33 PM
Vari93
Vari93 - avatar
- 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
15th Aug 2017, 11:25 AM
sayan chandra
sayan chandra - avatar