What I did yesterday: a simple algorithm, in python
from MITx: 6.00.2x Introduction to Computational Thinking and Data Science
Code Challenge:
Given a list of integers and a target integer, return a numpy array of 1 or 0 values, such that the sumproduct of the list and corresponding array returns the target integer. In the case of ties, return the numpy array with the fewest non-zero elements.
For example:
If choices = [1,2,2,3] and total = 4 you should return either [0 1 1 0] or [1 0 0 1]
If choices = [1,1,3,5,3] and total = 5 you should return [0 0 0 1 0]
If choices = [1,1,1,9] and total = 4 you should return [1 1 1 0]
See code here:
https://github.com/pkbanks/sum-prod-in-python/tree/master