A six-sided die has each of its sides labeled with a distinct letter. We
repeatedly roll it and record the result. We can only see three sides,
so each roll is recorded as a String of 3 letters, denoting the labels on
the visible sides in the order top,front,right.
______
/ A /|
/_____/ |
| |C|
| B | /
|_____|/
For the above roll, we should record "ABC"
We want to check the data for consistency -- we know that the data recording
process is error-prone.
Create a class AlphaDice that
contains a method badData that is given a String[] roll giving the recorded
data, and that returns
the (0-based) index of the first entry in roll that, when combined with its
predecessors, is inconsistent.
If all the roll data are consistent with some distinct labeling of the
die, return -1.
|