Combinations with repetition
Tests
| Test |
Method name |
Duration |
Result |
| Count matches multichoose formula: C(n+k-1, k) for n=5, k=3 |
countMatchesMultichoose() |
0s |
passed |
| Returned arrays are defensive copies (immutability) and fresh |
defensiveCopies() |
0s |
passed |
| Edge case: k=0 yields one empty combination (any n) |
edgeCaseKZero() |
0.001s |
passed |
| Edge case: n=0, k=0 emits one empty; n=0, k>0 emits none |
edgeCaseNZero() |
0s |
passed |
| Invalid arguments throw for negative k; n<0 rejected at of(n) |
invalidArgs() |
0.001s |
passed |
| Iterator respects hasNext()/next() and throws on exhaustion |
iteratorContract() |
0.001s |
passed |
| Lexicographic order for n=3, k=2 (nondecreasing arrays) |
lexOrderN3K2() |
0.001s |
passed |