[Challenge] Array's and numbers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

[Challenge] Array's and numbers

Create a function which accepts a sorted array(by size) which is type double. and a number. Then the function will check if any sum of 2 numbers from the array can create the number accepted by the function. if the duo exists the function will return True, otherwise it'll return false. And one last thing, only one iteration is allowed :) Any language is allowed. GL & HF My solution in python : https://code.sololearn.com/ciqsxjrZQovv/#py

25th Mar 2018, 7:16 PM
Tomer Sim
Tomer Sim - avatar
9 Answers
+ 14
https://code.sololearn.com/cthTsjEsWo9o/?ref=app
25th Mar 2018, 10:29 PM
LukArToDo
LukArToDo - avatar
26th Mar 2018, 9:45 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 8
@Tomer Sim Thank you for your mark 😊 You made me to think in a new way to solve this task. Thanks 😉
26th Mar 2018, 11:24 AM
LukArToDo
LukArToDo - avatar
+ 4
Louis, what you did is incorrect. you've iterated through the loop for more then one time. i asked for one time.
25th Mar 2018, 9:23 PM
Tomer Sim
Tomer Sim - avatar
+ 3
@~ swim ~ But they do? Mine works just fine.
28th Mar 2018, 8:37 AM
Tomer Sim
Tomer Sim - avatar
+ 3
well pal. if you didn't notice. 18.4+12.7 is not 31.1, it'll be 31.099999999 and you're invited to test it. i Thanks :)
28th Mar 2018, 3:58 PM
Tomer Sim
Tomer Sim - avatar
0
Implemented as a class extension recursion in Python. https://code.sololearn.com/c2uGK2DfblHd/?ref=app
26th Mar 2018, 3:19 PM
Edward
Edward - avatar
0
And I'm not sure if a statement like "if n in myList" should not also be considered an iteration...
27th Mar 2018, 8:52 AM
Edward
Edward - avatar