5 kyu

The Fruit Juice

1,002 of 1,427BattleRattle

Description:

In this kata we mix some tasty fruit juice. We can add some components with certain amounts. Sometimes we pour out a bit of our juice. Then we want to find out, which concentrations our fruit juice has.

Example:

  • You take an empty jar for your juice
  • Whenever the jar is empty, the concentrations are always 0
  • Now you add 200 units of apple juice
  • And then you add 200 units of banana juice
  • Now the concentration of apple juice is 0.5 (50%)
  • Then you pour out 200 units
  • The concentration of apple juice is still 50%
  • Then you add 200 units of apple juice again
  • Now the concentration of apple juice is 0.75, while the concentration of banana juice is only 0.25 (300 units apple juice + 100 units banana juice)

Complete the functions in order to provide this functionality. The test code for the example above can be found in the test fixture.

Object-oriented Programming
Algorithms

Stats:

CreatedOct 20, 2013
PublishedOct 20, 2013
Warriors Trained3443
Total Skips414
Total Code Submissions14798
Total Times Completed1427
JavaScript Completions1002
Python Completions423
Total Stars95
% of votes with a positive feedback rating90% of 194
Total "Very Satisfied" Votes164
Total "Somewhat Satisfied" Votes21
Total "Not Satisfied" Votes9
Ad
Contributors
  • BattleRattle Avatar
  • jhoffner Avatar
  • albertogcmr Avatar
  • farhanaditya Avatar
Ad