combinations icon indicating copy to clipboard operation
combinations copied to clipboard

returns excess combinations if min/max are the same

Open kurttheviking opened this issue 3 years ago • 2 comments

var combinations = require('combinations');
var arr = ['red', 'orange', 'yellow', 'green'];

combinations(arr, 2, 2)

Yields 12 combinations, including some that have 3 elements. Was expecting an array of size 6, with each result having exactly 2 elements.

kurttheviking avatar Mar 26 '21 14:03 kurttheviking

Same here

rwichmann avatar May 07 '21 12:05 rwichmann

if (got.length > 0 && got.length === max) { all[all.length] = got; } return;

Add this condition to solve your issue.

Harsh-Dobariya avatar Jul 22 '22 15:07 Harsh-Dobariya