7 kyu

Weight of its Contents

1,276 of 2,381dnolan

Description:

Welcome to the Mathematics gameshow. I'm your host, Apex Rhombus, and it's time for the lightning round!

Today we'll talk about a hypothetical bottle. This entire bottle weighs 120 grams. Its contents weigh twice as much as the bottle itself. What, may I ask, do the contents weigh?

...Did you guess 80 grams? Correct! Now that you've got that idea, I'm gonna ask you that question in 10 different ways so you'd better get ready!


Let's make a contentWeight function that takes in two parameters: bottleWeight and scale. This function will return the weight of the contents inside the bottle.

bottleWeight will be an integer representing the weight of the entire bottle (contents included).

scale will be a string that you will need to parse. It will tell you how the content weight compares to the weight of the bottle by itself. 2 times larger, 6 times larger, and 15 times smaller would all be valid strings (smaller and larger are the only comparison words).

The first test case has been filled out for you. Good luck!

Algorithms
Mathematics

Similar Kata:

More By Author:

Check out these other kata created by dnolan

Stats:

CreatedJun 6, 2014
PublishedJun 7, 2014
Warriors Trained4992
Total Skips560
Total Code Submissions13451
Total Times Completed2381
JavaScript Completions1276
Haskell Completions126
Ruby Completions263
CoffeeScript Completions19
C++ Completions279
C# Completions132
Python Completions379
Total Stars57
% of votes with a positive feedback rating91% of 318
Total "Very Satisfied" Votes265
Total "Somewhat Satisfied" Votes46
Total "Not Satisfied" Votes7
Ad
Contributors
  • dnolan Avatar
  • jhoffner Avatar
  • JoshSchreuder Avatar
  • bkaes Avatar
  • Chrono79 Avatar
  • milxan Avatar
  • Voile Avatar
  • hobovsky Avatar
  • albertogcmr Avatar
Ad