Skip to content

Latest commit

 

History

History
62 lines (32 loc) · 878 Bytes

File metadata and controls

62 lines (32 loc) · 878 Bytes

8 balls problem


Finds the appropriate number of weighings for each number of balls

Description:

The inspiration is a puzzle with 8 balls and a scale. This program calculates the minimum number of weighings needed to find the heavier ball among a given number of balls.


Functions:

Calculates the minimum number of weighings using mathematical formula:

$⌊log3(numberOfBalls-1)⌋+1 $

Takes the number of balls as input from the user. Displays the minimum number of weighings as output.


Example of use:

Enter the number of balls: 8

The minimum number of weighings is: 2


Requirements:

Python 3.x

NumPy library


Installation:

pip install numpy


Use:

Run python maincode.py


License:

MIT License