OK, I'm convinced of the logic now. But I don't think that bool should be used here since bool(x<=2) is True even though Piecewise wouldn't select on this basis. Also we needn't run through the check if we already have the solution, so we could first put

```
if candidate in result:
    continue
```