All problems
Timing Wheel Bucket Index
Problem
Compute the bucket and round for a timer in a hashed timing wheel.
Given the current tick, the number of wheel slots, and a delay in ticks, the fire time is tick + delay. The bucket is that time modulo the wheel size and the round counts how many full revolutions must pass first.
Return [bucket, round].
Hint
Modulo selects the slot and integer division counts the cascades.
Test cases
case 1
in: [0,8,5]
expected: [5,0]
case 2
in: [3,8,10]
expected: [5,1]
case 3
in: [7,4,1]
expected: [0,2]
case 4
in: [0,1,0]
expected: [0,0]
Starter codePython
def timing_wheel_bucket(tick, wheel_size, delay):
# Your code here
pass4 test cases · run your code against them in the editor