Problem Statement | |||||||||||||
A pharmacist is making a mixture of several ingredients. She needs to know the density of the resulting mixture. Density is defined as the mass of the mixture divided by its volume. You're given a String[] ingredients, each element of which describes a single ingredient and is formatted "<Volume> ml of <Name>, weighing <Mass> g" (quotes for clarity). <Volume> and <Mass> are integers representing the volume in milliliters and mass in grams, respectively. <Name> is the name of the ingredient. Return the density of the resulting mixture in grams per milliliters. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | The returned value must be accurate to within a relative or absolute value of 1E-9. | ||||||||||||
Constraints | |||||||||||||
- | ingredients will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of ingredients will contain between 23 and 50 characters, inclusive. | ||||||||||||
- | Each element of ingredients will be formatted as described in the statement. | ||||||||||||
- | Each <Volume> in ingredients will be an integer between 1 and 1000, inclusive, with no leading zeroes. | ||||||||||||
- | Each <Mass> in ingredients will be an integer between 1 and 1000, inclusive, with no leading zeroes. | ||||||||||||
- | Each <Name> in ingredients will contain only lowercase letters ('a'-'z') and spaces (' '). | ||||||||||||
- | Each <Name> in ingredients will begin and end with a lowercase letter. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|