Combining without repetitions doesn't work properly if source has repeated elements
robertsynoradzki opened this issue · 2 comments
robertsynoradzki commented
"aab".Permute(GenerateOptions.WithoutRepetition)
bears different amount of elements than
"abc".Permute(GenerateOptions.WithoutRepetition)
as if the source was treated by .Distinct()
inside.
This is not an expected behaviour. In math problems where source can have repeated elements (e.g. building words from a given set of letters), repeated elements should be treated uniquely.
For example, this problem cannot be easily solved because of this behavour.
Suggestion: iterate elements by index, not value.
robertsynoradzki commented
For reference, check how this library does it.
TommasoScalici commented
You're right, and this should now be fixed in the latest issued commit. Let me know if you're experiencing other strange / unexpected behaviors.