18 lines
513 B
Python
18 lines
513 B
Python
def egg_count(display_value):
|
|
number_of_eggs: int = 0
|
|
weight: int = 1
|
|
while display_value % weight != display_value:
|
|
weight *= 2
|
|
while display_value:
|
|
if display_value == weight:
|
|
number_of_eggs += 1
|
|
display_value -= weight
|
|
if display_value < weight:
|
|
weight //= 2
|
|
continue
|
|
if display_value % weight:
|
|
number_of_eggs += 1
|
|
display_value -= weight
|
|
weight //= 2
|
|
return number_of_eggs
|