Next pattern in sweep
Your task
A soak test rig energizes relay lines in patterns. Bit i of a pattern is set when line i is energized, and slots gives how many lines the rig has, at most 30. A sweep visits every pattern that energizes exactly as many lines as the one it began with, taking them in ascending numeric order. The log names pattern as the last one that finished, and says skipped further patterns ran unrecorded before the rig died. Return the pattern the rig should restart from, the one sitting skipped places after pattern in that ascending order, or -1 when the order runs out first. A skipped of 0 asks for pattern itself. skipped can reach into the hundreds of millions, so stepping one pattern at a time will not finish.
Examples
resume_sweep_pattern(pattern: int, slots: int, skipped: int) -> intExample 1
Input
resume_sweep_pattern(5, 4, 1)Output
6Example 2
Input
resume_sweep_pattern(3, 3, 2)Output
6Example 3
Input
resume_sweep_pattern(12, 4, 1)Output
-1