Statistics

Problem Statement for "ChemMix"

Problem Statement

A machine is programmed to automatically mix two chemicals. The machine begins with Bowl A filled with 360000 units of chemical 1 and Bowl B filled with 360000 units of chemical 2. Define a "mix" as follows:

  1. The machine pours 120000 units of liquid from Bowl A to Bowl B and stirs Bowl B until the liquid is well mixed.
  2. The machine pours 120000 units of liquid from Bowl B to Bowl A and stirs Bowl A until the liquid is well mixed.

Given an int mixes, return the number of units of chemical 1 in Bowl B after the machine performs the above procedure mixes amount of times.

If the amount of chemical 1 that needs to make up the 120000 units for pouring is not an integer, then round down the number of chemical 1 units for pouring. For example, if there are 180001 units of chemical 1 out of 360000 in Bowl A, then to pour 120000 units into Bowl B, there should be 60000.33 units of chemical 1 in the 120000, so just consider the 120000 units to be 60000 parts chemical 1, 60000 parts chemical 2. Similarly, if there are 240001 units of chemical 1 out of 480000 in Bowl B, then to pour 120000 units back into Bowl A, there should be 60000.25 units of chemical 1, so just consider the 120000 units to be 60000 parts chemical 1, 60000 parts chemical 2.

Definition

Class:
ChemMix
Method:
partsChem
Parameters:
int
Returns:
int
Method signature:
int partsChem(int mixes)
(be sure your method is public)

Constraints

  • mixes is an int between 0 and 100, inclusive.

Examples

  1. 0

    Returns: 0

    If there has not been any mixing done, then the amount of chemical 1 in Bowl B has not changed.

  2. 1

    Returns: 90000

    After pouring from bowl A to bowl B, bowl A has 240000 units of chemical 1 and bowl B has 120000 units of chemical 1 (and 360000 parts chemical 2). Then, after pouring from bowl B to bowl A, 1/4 of the 120000 units are chemical 1 units, so 30000 chemical 1 units are returned to bowl A. Bowl B now has 120000 - 30000 = 90000.

  3. 5

    Returns: 174375

  4. 100

    Returns: 180000

  5. 17

    Returns: 179999

  6. 19

    Returns: 180000

  7. 20

    Returns: 180000

  8. 70

    Returns: 180000

  9. 18

    Returns: 180000

  10. 26

    Returns: 180000

  11. 72

    Returns: 180000

  12. 97

    Returns: 180000

  13. 56

    Returns: 180000

  14. 1

    Returns: 90000

  15. 8

    Returns: 179297

  16. 52

    Returns: 180000

  17. 13

    Returns: 179979

  18. 100

    Returns: 180000

  19. 79

    Returns: 180000


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: