combinations with varying length and without repetition
问题 Can anyone suggest an easy way of getting all combinations without repeats, and with a varying length ? [0,1,2,3,4] (2's) : [0,1],[0,2],[0,3] ... [3,4] (3's) : [0,1,2],[0,1,3] ... [2,3,4] (4's) : [0,1,2,3],[0,1,2,4] ... [1,2,3,4] 回答1: took me a while but I think I've got it here... this has all the combinations without repeats var arr:Array = [0, 1, 2, 3, 4]; var $allcombos:Array = []; findCombos($allcombos,[],arr); function findCombos($root:Array, $base:Array, $rem:Array):void { for (var i