One empty combination
The combination generator loses the valid zero-choice case.
What’s going wrong
A generator builds every combination by choosing one value from each group. Ordinary groups work, but a configuration with no groups generates no result. The caller expects one empty combination: there is exactly one way to choose nothing.
Input starts with the number of groups. Each following line contains that group's space-separated signed integers; an empty line is an empty group. Print all combinations in Rust debug list format, preserving group and value order. Zero groups must produce `[[]]`. A present but empty group makes the result `[]`. Inputs contain at most four groups and four numbers per group.
Fix the generator while retaining its behavior for ordinary groups.
Expected behavior
Zero groups produce one empty combination. Any empty group produces none. All other groups produce their full ordered Cartesian product.
Reproduction
0
[[]]
2 1 2 3 4
[[1, 3], [1, 4], [2, 3], [2, 4]]
Before you begin
- Functions
- Vectors
- Loops
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.