RosePetals
SRM 315 · 2006-08-09 · by Cosmin.ro
Problem Statement
"Petals Around the Rose" is a pretty well known logic game. A person who knows the game rolls five dice and then says a number. The other players must guess the rule used to obtain that number. We will not ask you to play this game because it's a tricky one. We will simply tell you that the rule is to sum the number of dots that are around the center dot of each die, like the petals around a rose. If a die has no dot in the center, it has no petals. The face of the die labeled with 1 dot has 0 petals, the face with 2 dots has 0 petals, the face with 3 dots has 2 petals, the face with 4 dots has 0 petals, the face with 5 dots has 4 petals and finally the face with 6 dots has 0 petals as can be seen in the picture.
You are given a
Constraints
- dice will contain exactly 5 elements.
- Each element of dice will be between 1 and 6, inclusive.
{1, 2, 3, 2, 1}
Returns: 2
In this case we have 0 petals for 1 as there are no dots around the central dot, 0 petals for 2 as it has no central dot, 2 petals for 3, 0 petals for 2 and 0 petals for 1.
{4, 4, 5, 6, 5}
Returns: 8
In this case we have 0 petals + 0 petals + 4 petals + 0 petals + 4 petals = 8 petals.
{1, 2, 3, 3, 5}
Returns: 8
{3, 3, 3, 3, 3}
Returns: 10
{2, 2, 2, 2, 2}
Returns: 0
Submissions are judged against all 64 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RosePetals with a public method int getScore(vector<int> dice) · 64 test cases · 2 s / 256 MB per case