Skip to content

Instantly share code, notes, and snippets.

View pratikt-cuelogic's full-sized avatar

Pratik Tayade pratikt-cuelogic

View GitHub Profile
@lrvick
lrvick / subsetsum.js
Created November 20, 2011 22:43
Subset-Sum Solution in javascript
var subset_sum = function(items, target) {
var perms = [], layer = 0, depth = 4, attempts = 0, sum, perm,
ss = function(items) {
var item = items.shift();
for (i = 0; i < items.length; i++) {
attempts = attempts + 1;
if (attempts <= items.length * items.length) {
if (layer === 0) {
perm = [items[0], items[i]];
} else {