3 ms·
Nice. You need to initialize x to 0 instead of -m&m though, or you miss the solution with x=0.
by Strilanc 3y ago
Nice. You need to initialize x to 0 instead of -m&m though, or you miss the solution with x=0.
- pbsd 3y agox=0 is the last solution to be hit the way I wrote it.
- Strilanc 3y agoIt's possible I misdiagnosed the issue. But I implemented the code and ran it and counted the solutions, and one was missing. I changed that line and it fixed it, and the solution that was missing is the one I described. In any case, it's a nice succinct trick for iterating through the values compatible with a mask. Getting the boundary conditions right is less important than knowing the trick.