combinations: count and size_hint#729
Merged
phimuemue merged 14 commits intoAug 18, 2023
Merged
Conversation
Because we give combinations in the lexicographic order, we can use the indices to count the remaining combinations to come. We are gonna heavily test it thought.
The whole point of the lazy buffer is to not fill the pool all at once but in some cases we want to, and then it's better than do it with `while lazy_buffer.get_next() {}` that would be weird.
phimuemue
requested changes
Aug 16, 2023
Member
phimuemue
left a comment
There was a problem hiding this comment.
Hi @Philippe-Cholet I tried to review, and I have some questions.
I think the most difficult part for me is to understand remaining_for.
`pool.it.count()` consumes `pool` before we call `remaining_for` so it can not be a method and therefore becomes a free function.
phimuemue
requested changes
Aug 17, 2023
Member
phimuemue
left a comment
There was a problem hiding this comment.
Thanks for the update. We should comment the sources for the complex algorithms and add some tests, then I think we're good to go.
And add todo
Only test for `n <= 500` but only a few values of the last row do not already have overflow on a 64 bits computer. NOTE: Not faster with an array updated in-place.
Member
Author
|
All changes are done (with a limit of 500 for Ready to squash everything into one commit. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The indices we track (to give combinations in the lexicographic order) can help us count the remaining combinations.
@phimuemue That's all for combinations. Each commit is as small as possible. Similar work for other iterators to come, but this should be the biggest as it prepares work for
powersetandcombinations_with_replacement.