0
Challenge : sum finder
Make a function that takes an array with N distinct integers and a target S and returns the number of ways to add at most N numbers (duplicates allowed) taken from.the array and reach a sum S. Ex : [1,2,3],7 => 2 ways to sum to 7 because 3+3+1=3+2+2=7 (1+1+1+1+1+1+1 or 3+1+1+2 dont work because it needs more than 3 numbers)
6 Respuestas
+ 2
as u said...
a bonus one liner...
change...sum number
change array for further checking
https://code.sololearn.com/cjtIVHtkAmOH/?ref=app
+ 11
Interesting challenge, thank you 👍
Here's my try :
https://code.sololearn.com/cUS6UH5Dxmql/?ref=app
+ 1
heres mine...
## i initialised the array...as 1, 2, 3, 4
## u can change it to anything u want
## input the number to het summed up
## Bonus>>
it will show u each combination from 1 to your entered number
((time limit may exceed for higher numbers))
((try 20 *just a random perfect example*))
https://code.sololearn.com/cafLUYjbOfCS/?ref=app
0
The answers must have at most N numbers :-(
- 1
Bonus for whoever does a one liner functional version !