Skip to content

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.

License

Notifications You must be signed in to change notification settings

RooTinfinite/balls-problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages