Skip to content

Instantly share code, notes, and snippets.

@andijcr
Created November 9, 2013 14:01
Show Gist options
  • Save andijcr/7385710 to your computer and use it in GitHub Desktop.
Save andijcr/7385710 to your computer and use it in GitHub Desktop.
mele = ['annurca', 'fuji','cox', 'golden','renetta', 'granny smith', 'elstar', 'pink lady']
partitions = function (set, n){
var albero={}
if(n>0){
for(var i=0; i< set.length; i++){
var tset=set.slice()
var key=tset.splice(i,1)[0];
albero[key]=partitions(tset, n-1)
}
}
return albero
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment