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
Definition
- Class:
- RosePetals
- Method:
- getScore
- Parameters:
- int[]
- Returns:
- int
- Method signature:
- int getScore(int[] dice)
- (be sure your method is public)
Constraints
- dice will contain exactly 5 elements.
- Each element of dice will be between 1 and 6, inclusive.
Examples
{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
{1, 2, 3, 4, 5}
Returns: 6
{6, 6, 6, 6, 6}
Returns: 0
{5, 5, 5, 5, 5}
Returns: 20
{1, 1, 1, 1, 1}
Returns: 0
{2, 2, 2, 2, 2}
Returns: 0
{3, 3, 3, 3, 3}
Returns: 10
{4, 4, 4, 4, 4}
Returns: 0
{5, 4, 4, 1, 4}
Returns: 4
{3, 2, 5, 3, 3}
Returns: 10
{2, 6, 4, 2, 4}
Returns: 0
{2, 6, 6, 4, 2}
Returns: 0
{6, 6, 1, 3, 5}
Returns: 6
{3, 2, 1, 4, 4}
Returns: 2
{1, 3, 6, 3, 2}
Returns: 4
{6, 4, 2, 4, 3}
Returns: 2
{3, 3, 6, 3, 4}
Returns: 6
{1, 1, 1, 3, 6}
Returns: 2
{6, 6, 5, 1, 5}
Returns: 8
{2, 1, 1, 3, 2}
Returns: 2
{6, 2, 4, 3, 4}
Returns: 2
{3, 2, 3, 2, 4}
Returns: 4
{3, 4, 3, 4, 1}
Returns: 4
{3, 4, 3, 4, 6}
Returns: 4
{4, 1, 5, 3, 1}
Returns: 6
{1, 2, 1, 2, 6}
Returns: 0
{1, 2, 1, 5, 1}
Returns: 4
{1, 6, 3, 5, 3}
Returns: 8
{3, 3, 4, 4, 6}
Returns: 4
{5, 2, 1, 4, 5}
Returns: 8
{4, 2, 6, 3, 5}
Returns: 6
{6, 4, 6, 5, 6}
Returns: 4
{3, 1, 3, 6, 6}
Returns: 4
{2, 6, 1, 4, 1}
Returns: 0
{4, 3, 2, 3, 3}
Returns: 6
{5, 5, 5, 4, 1}
Returns: 12
{6, 4, 1, 2, 2}
Returns: 0
{2, 1, 4, 4, 6}
Returns: 0
{4, 3, 4, 5, 3}
Returns: 8
{5, 1, 1, 2, 1}
Returns: 4
{1, 1, 6, 2, 4}
Returns: 0
{2, 4, 4, 6, 3}
Returns: 2
{2, 5, 3, 4, 2}
Returns: 6
{2, 4, 4, 2, 1}
Returns: 0
{2, 6, 5, 6, 2}
Returns: 4
{4, 2, 4, 6, 6}
Returns: 0
{5, 2, 4, 1, 3}
Returns: 6
{3, 1, 5, 2, 6}
Returns: 6
{1, 2, 4, 2, 1}
Returns: 0
{5, 6, 1, 1, 5}
Returns: 8
{4, 4, 4, 1, 3}
Returns: 2
{2, 4, 6, 5, 5}
Returns: 8
{1, 3, 3, 4, 6}
Returns: 4
{4, 5, 6, 4, 5}
Returns: 8
{1, 5, 5, 3, 1}
Returns: 10
{3, 6, 1, 3, 1}
Returns: 4
{3, 5, 6, 5, 5}
Returns: 14
{5, 4, 1, 6, 6}
Returns: 4
{4, 4, 5, 6, 5 }
Returns: 8
{5, 6, 5, 4, 5 }
Returns: 12