Skip to contentKEEP THE CRAFTTHE SANCTUARY

Smallest Square That Fits

Binary-search the smallest square side that can hold a given number of items.

The problem

Implement minimum_square_side(item_count). A square with side length side holds side * side items. Return the smallest nonnegative integer side whose square holds at least item_count items. For example, 10 items need side 4 (side 3 holds only 9), and 25 items need side 5. item_count is a nonnegative integer; 0 items need side 0.

Starter code

def minimum_square_side(item_count):
    pass

Public examples

  1. item_count = 10gives4
  2. item_count = 25gives5

Solving it in the practice book needs an active paid plan.

Open it in the practice book
One thought at a time.