Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.29 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Recursive version
  2.  
  3. function isMeasurable(target, weights)
  4. {
  5.     if (weights.length == 0)
  6.         return target == 0;
  7.  
  8.     var first = weights.shift();
  9.     return
  10.         isMeasurable(target-first, weights) ||
  11.         isMeasurable(target+first, weights) ||
  12.         isMeasurable(target, weights);
  13. }