title: Efficient algorithm to remove bad numbers from sets
body: <p>Given are a number of finite sets of integers, for example:</p>
  
  <pre><code>A = {1,2,3}
  B = {2,3,4}
  C = {3,4,5}
  </code></pre>
  
  <p>and also a number, for example 6. The question is to determine from the sets the numbers that cannot be used to sum 6 by selecting one number from each set. For example the 1 in A is valid, because 1+2+3=6 (the 2 coming from B and the 3 from C). The 5 from the C is not valid, because you can't sum to 6 by using the 5 (you will always get at least 1+2+5=8).</p>
  
  <p>How can you do this efficiently?</p>