Find the winner of the Josephus problem for num_people and a step_size. Args: num_people (int): Number of people. step_size (int): Step size for elimination. Returns: int: The position of the last person remaining (1-based index). Examples: >>> fin
(num_people: int, step_size: int)
| 78 | |
| 79 | |
| 80 | def find_winner(num_people: int, step_size: int) -> int: |
| 81 | """ |
| 82 | Find the winner of the Josephus problem for num_people and a step_size. |
| 83 | |
| 84 | Args: |
| 85 | num_people (int): Number of people. |
| 86 | step_size (int): Step size for elimination. |
| 87 | |
| 88 | Returns: |
| 89 | int: The position of the last person remaining (1-based index). |
| 90 | |
| 91 | Examples: |
| 92 | >>> find_winner(7, 3) |
| 93 | 4 |
| 94 | >>> find_winner(10, 2) |
| 95 | 5 |
| 96 | """ |
| 97 | return josephus_recursive(num_people, step_size) + 1 |
| 98 | |
| 99 | |
| 100 | def josephus_iterative(num_people: int, step_size: int) -> int: |
nothing calls this directly
no test coverage detected