AlphaDice
SRM 167 · 2003-10-14 · by dgoodman
Problem Statement
______
/ 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
If all the roll data are consistent with some distinct labeling of the die, return -1.
Constraints
- roll will contain between 1 and 50 elements inclusive
- each element of roll will have length 3 and will contain only 'A'-'Z'
{"ABC","ZCB"}
Returns: -1
This is the example above where there is a Z on the bottom. On the second roll the die was oriented so the Z was on the top, the C at the front, and the B on our right. These data are consistent with a distinctly labeled die.
{"ABC","DEF","BCA","GHI","ABC"}
Returns: 3
The first 3 were consistent with a die with 6 distinct labels, but the "GHI" must be bad data since we could not possibly observe more than 6 different labels.
{"ABA","CDE","CDE","CDE","CDE"}
Returns: 0
The first observation shows two sides labeled with 'A'
{"TFR","TLF","TBL","TRB","URF","ULF","ULB","UBR","RTF","RBT","RUB","RFU","TBL"}
Returns: 5
{"TFR","TLF","TBL","TRB","URF","UFL","ULB","UBR","RTF","RBT","RUB","RFU","TBL"}
Returns: -1
Submissions are judged against all 100 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class AlphaDice with a public method int badData(vector<string> roll) · 100 test cases · 2 s / 256 MB per case