//Today's Challenge // triangle number in a list or array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

//Today's Challenge // triangle number in a list or array

Given a list/array of numbers try to identify the numbers in the list whose previous number is their triangle number Triangle no eg. If n is a triangle number of x then 1+2+3+... +(n-1)+(n)=x Eg. List = [4,5,3,6,7,28] Output = [6,28] Since 3 and 7 are there triangle numbers

18th Nov 2017, 5:23 AM
Utkarsh Dhawan
5 Answers
+ 12
Thank you for the challenge. Here's my try : https://code.sololearn.com/cbGNKV5h4wIU/?ref=app
18th Nov 2017, 7:10 PM
LukArToDo
LukArToDo - avatar
18th Nov 2017, 7:58 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
19th Nov 2017, 11:00 AM
David Akhihiero
David Akhihiero - avatar
+ 5
💟💟🎉🎉🎉 finally, all is done,, Here is the full solution with printed results too. https://code.sololearn.com/WyOG7vaxzWLG/?ref=app
19th Nov 2017, 6:27 PM
raz
raz - avatar
+ 4
Tried with functional programming. Would never do it again. https://code.sololearn.com/cL6Uy6H47e3H/?ref=app
19th Nov 2017, 12:02 PM
Oma Falk
Oma Falk - avatar