From 243b3ffcc05080a67115c863c2a5b1cc1c63fd31 Mon Sep 17 00:00:00 2001 From: Attila Bagossy Date: Sun, 29 Jan 2017 17:55:01 +0100 Subject: [PATCH] permutation uses bigCombination for 31 elements or more --- combinatorics.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/combinatorics.js b/combinatorics.js index fad089d..081e4ef 100644 --- a/combinatorics.js +++ b/combinatorics.js @@ -332,7 +332,13 @@ return size; }, init: function() { - this.cmb = combination(ary, nelem); + /* combination can only be used for less than 31 elements */ + if (ary.length < 31) { + this.cmb = combination(ary, nelem); + } else { + this.cmb = bigCombination(ary, nelem); + } + this.per = _permutation(this.cmb.next()); }, next: function() {