Skip to content

returns excess combinations if min/max are the same #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kurttheviking opened this issue Mar 26, 2021 · 2 comments
Open

returns excess combinations if min/max are the same #11

kurttheviking opened this issue Mar 26, 2021 · 2 comments

Comments

@kurttheviking
Copy link

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 kurttheviking changed the title returns invalid combinations if min/max are the same returns excess combinations if min/max are the same Mar 26, 2021
@rwichmann
Copy link

Same here

@Harsh-Dobariya
Copy link

Harsh-Dobariya commented Jul 22, 2022

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

Add this condition to solve your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants