fork(5) download
  1. def r(a,c=[],z=[]):
  2. a.sort()
  3. for i,v in enumerate(a):z+=[c+[v]]if v+sum(c)==10*0**(c+[v]in z)else r(a[i+1:],c+[v],z)*0
  4. return z
  5.  
  6.  
  7. res = r( [1,4,5,5,2,3,1,4] )
  8. print( res )
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
[[1, 1, 3, 5], [1, 1, 4, 4], [1, 2, 3, 4], [1, 4, 5], [2, 3, 5], [2, 4, 4], [5, 5]]