recursion: find all ways to add elements in an list to get to n in python

后端 未结 0 608
一向
一向 2021-01-22 01:21

For example,

given a list [1,2,3,4] and `n=4`

my output should be

7:
1+1+1+1=4
1+1+2=4
1+2+1=4
1+3=4
2+2=4
2+1+1=4
3+1=4


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题