Write a function that gets as an input a sorted array of positive numbers A, and an additional number n. The Task is to print out all distinct subsets of A, that sum to n.
Example:
Input: A = [1,2,2,4,4] n = 9 Output: [1,2,2,4] [1,4,4] Bonus: -50% if your code doesn't store duplicate subset (the same subset but in different order) intern. The function will not store more than one duplicate subset in memory at a time.
Shortest code in bytes wins.