Problem Statement | |||||||||||||
Let I_Zero denote the real interval from 0 to 1/3, including 0 but not including 1/3. Let I_One denote
the real interval from 1/3 to 1 including both endpoints.
We have a dynamic system, in which real values are generated by the following rule: xt+1 = f(xt) where f is the function f(x) = 3x (for x in I_Zero) (3-3x)/2 (for x in I_One)The trajectory of a value c is the sequence of real values that would be generated by the system starting with c. These would be c, f(c), f(f(c)), etc. The "itinerary" of c is defined to be the sequence of 0's and 1's indicating whether the corresponding trajectory values are in I_Zero or I_One. For example, the trajectory of 1/2 is 1/2,3/4,3/8,15/16,3/32,9/32, ... so its itinerary is 1,1,1,1,0,0,... Given a value and the itinerary of an unknown value c, we would like to determine whether the given value is less than or greater than c. Since an itinerary is an infinite sequence, we will be given only the first part of an itinerary, so it may be impossible to determine whether the given value is smaller or larger than c. Create a class Symbolic that contains a method compare that is given value as a decimal String and a int[] itin (the first elements in the itinerary of the unknown c). The method returns -1, 0, or 1 depending on whether value is less than c, indeterminate, or greater than c. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | value will contain between 2 and 20 characters inclusive. | ||||||||||||
- | value will consist of a decimal point followed by digits '0'-'9'. | ||||||||||||
- | itin will contain between 1 and 50 elements inclusive. | ||||||||||||
- | Each element of itin will be 0 or 1. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|