Skip to content
DeepForgeby svx
All problems
EasyData Structuresds-269

Clock Hand Advance

Problem

Advance a clock replacement hand around a circular buffer of frames.

num_frames is the frame count, start is the current hand position, and steps is the number of advances. Positions wrap modulo the frame count.

Return the new hand position.

Hint

The hand position is just a sum taken modulo the frame count.

Test cases

case 1
in: [4,0,1]
expected: 1
case 2
in: [4,3,5]
expected: 0
case 3
in: [1,0,7]
expected: 0
case 4
in: [4,0,0]
expected: 0
Starter codePython
def clock_hand_advance(num_frames, start, steps):
    # Your code here
    pass

4 test cases · run your code against them in the editor