Giter Site home page Giter Site logo

balancedcentrifugeproblem's Introduction

balancedCentrifugeProblem_C

Description

Implementation of The Balanced Centrifuge Problem using the the C language.

This is one of the, probably many, ways to simulate this mathematical problem.

The Problem:

A centrifuge is a laboratory device which spins liquid samples at high speed in order to separate them based on density. It’s very important to balance a centrifuge before operating it - not doing it by using, for example, just a tube on only one side, the rotating mass will not be balanced causing the centrifuge to shake when rotating and may even damage the centrifuge or the tube. A tube on the opposite side is used to balance the mass for smooth operation.

So, a centrifuge is balanced if the center of mass of the collection of test tubes coincides with the center of mass of the centrifuge itself.

The problem is - given the number of holes in the centrifuge - for which different numbers of test tubes can you obtain a balanced-configuration?

The Solution:

(1) Number of Test Tubes.
(2) Number of Empty Spots in the Centrifuge.
(3) Number of Holes in the Centrifuge.

You can balance the centrifuge if and only if both (1) and (2) can be written as sums of prime factors of (3).

Example 1:

For the case of a centrifuge with 12-holes.

The prime factors of 12 are 2 and 3.

You can have a balanced-configuration for 2, 3, 4, 5, 6, 7, 8, 9, 10, 12 test tubes in a 12-hole centrifuge.

*Notice that, for example, for 5 test tubes, you have
(1) Number of Test Tubes = 5;
(2) Number of Empty Holes = 12 - 5 = 7.

Being that the prime factors of 12 are 2 and 3, you can easily see that you can write (1) and (2) as sums of those prime factors.
(1) 5 = 2 + 3;
(2) 7 = 2 + 2 + 3;

So, you can have a 5 tubes balanced in a 12-hole centrifuge.

Example 2:

In the other hand, it's easy to understand that if you have 11 test tubes you will never be able to have a balanced-configuration.

(1) Number of Test Tubes = 11.
(2) Number of Empty Holes = 12 - 11 = 1.

You can't write (1) or (2) as sums of the prime factors of 12 (which are, again, 2 and 3).

balancedcentrifugeproblem's People

Contributors

davidrferreira avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.