r = ->(a){(1..a.size).flat_map{|n|a.sort.combination(n).select{|c|c.reduce(:+)==10}.uniq}} p r.([5, 2, 3, 5])