Skip to content
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

possible repeat combination is the same item value is repeated in the container #10

Open
vickoza opened this issue Nov 18, 2020 · 2 comments

Comments

@vickoza
Copy link

vickoza commented Nov 18, 2020

std::vector<int> test = {1,1,2,3,4,5};
auto count = 0;
for (auto&& x : discreture::combinations(test, 3))
    std::cout << ++count << " -- "<< x << '\n';

1 -- 1 1 2
2 -- 1 1 3
3 -- 1 2 3
4 -- 1 2 3
5 -- 1 1 4
6 -- 1 2 4
7 -- 1 2 4
8 -- 1 3 4
9 -- 1 3 4
10 -- 2 3 4
11 -- 1 1 5
12 -- 1 2 5
13 -- 1 2 5
14 -- 1 3 5
15 -- 1 3 5
16 -- 2 3 5
17 -- 1 4 5
18 -- 1 4 5
19 -- 2 4 5
20 -- 3 4 5

@mraggi
Copy link
Owner

mraggi commented Feb 2, 2021

Yeah, the way it is written, it is "impossible" to fix. Maybe we could write a different way of doing it to take care of this issue. I'll think about this.

@vickoza
Copy link
Author

vickoza commented May 4, 2021

You could create a function combinationValues where you copy the container elements into a local container then sort and pass the container to unique and finally call the combinations function on the local container

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

2 participants