PROBLEM STATEMENT
Consider the sequence of numbers:
1, 11, 21, 1211, 111221, 312211, ...
in which each number "describes" the number before it. For example, the fifth
number in the sequence is 111221, or "three one's, two two's, one one". So the
sixth element is the concatenation of 31 ("three one's"), 22 ("two two's"), and
11 ("one one"), or 312211.
Starting with a different number, we obtain a different sequence. For example,
starting with "70" yields the sequence:
70, 1710, 11171110, 31173110, ...
Write a class Describes which contains a method elementAt. elementAt returns
the number at the specified index of the sequence defined above, starting with
the value startValue. Return the answer as a String. Here, startValue is
defined to be at index 0 of the sequence. So elementAt( 1, 0 ) returns "1"
while elementAt( 70, 3 ) returns "31173110".
DEFINITION
Class: Describes
Method Name: elementAt
Parameters: int, int
Returns: String
Method signature (be sure your method is public): String elementAt(int
startValue, int index);
NOTES
Each pair of digits that describes part of the previous element must describe a
maximal group of one or more consecutive identical digits. For example, the
element "44" may not be described by "0124" (zero ones, two fours), nor may it
be described by "1414" (one four, one four). "44" must be described by "24"
(two fours).
TopCoder will ensure the validity of the inputs. Inputs are valid if all of
the following criteria are met:
* startValue is between 1 and 999, inclusive
* index is between 0 and 6, inclusive
Some more examples:
elementAt( 70, 0 ) returns "70"
elementAt( 1, 5 ) returns "312211"
elementAt( 788, 6 ) returns "31131122211711131221121113122118"