Problem Statement | |||||||||||||
You will be given a String, eq, representing some simple addition. It will be formatted as a sequence of terms separated by single plus signs. Each term will be either an integer between 0 and 1000, inclusive, or a sequence of lowercase letters, representing a variable. The values of all the variables in eq will be given in a String[], vars, each element of which will be formatted as "VARIABLE VALUE". You should return the sum represented by eq. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | eq will be formatted as described in the problem. | ||||||||||||
- | eq will contain at least one plus sign. | ||||||||||||
- | eq will contain between 3 and 50 characters, inclusive. | ||||||||||||
- | Each element of vars will be formatted as "VARIABLE VALUE", where VARIABLE is a sequence of lowercase letters and VALUE is an integer between 0 and 1000, inclusive. | ||||||||||||
- | None of the integers in the input will have extra leading zeros. | ||||||||||||
- | Each variable in eq will be present in vars. | ||||||||||||
- | Each variable in vars will be present in eq, and no variable will occur more than once in vars. | ||||||||||||
- | Each element of vars will contain at most 50 characters. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
|