Skip to content
DeepForgeby svx
All problems

Successive Halving Elimination

Problem

Select the configurations that survive one round of successive halving.

Keep the top ceil(n / eta) configurations by score (ties broken by smaller index) and return the surviving indices in ascending order. If eta <= 1 or there are no configurations, return [].

Hint

Eta is the reduction factor; half the field survives when eta is 2.

Test cases

case 1
in: [[1,5,3,2],2]
expected: [1,2]
case 2
in: [[9,4,4,1,0],3]
expected: [0,1]
case 3
in: [[2],2]
expected: [0]
case 4
in: [[1,2],1]
expected: []
Starter codePython
import math
def successive_halving_keep(scores, eta):
    # Your code here
    pass

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