Leaving the circle

Write code · Challenge · §5.2 Queues

Students numbered 1 to n stand in a circle in order of their numbers. Counting starts from student 1, and the k-th student counted leaves the circle. Then the count starts over at 1 with the student right after the one who left.

This repeats until every student has left. Complete the function solution, which returns a list of the student numbers in the order the students leave.

Function

solution(n, k)

Constraints

Examples

nkresult
52[2, 4, 1, 5, 3]
31[1, 2, 3]

Starter code

def solution(n, k):
    answer = []
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.