Skip to content

About

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.

Resources

Stars

7 stars

Watchers

1 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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.

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages