How many petals around the rose How many petals around the rose
How many petals around the rose is a dice game you can play with your friends. Similar to &quot;can I join the music box&quot;, there is a person that knows how the game works and the others have to discover the rule.
In this game, someone rolls some dice (usually two or more) and then people have to call &quot;how many petals are around the rose&quot;.
Algorithm
If you want to play it by yourself, you can play it over at TIO. Just hide the header (which is where the rule is implemented) and try passing different arguments (from 1 to 6) in the function.
spoiler, what follows is the rule you are invited to find by yourself!

 The &quot;roses&quot; here are the dice, and the &quot;petals&quot; are the black dots that are around a central dot. Because only the odd numbers have a central black dot, only numbers 1, 3, 5 matter for the petals. Those numbers have, respectively, 0, 2, 4 dots around the central dot, the &quot;petals&quot;.


Input
Your input will be a non-empty list (or equivalent) of integers in the range [1, 6].
Output
The number of petals around the rose.
Test cases
Reference implementation in Python, that also generated the test cases.
1, 1 -&gt; 0
1, 2 -&gt; 0
1, 3 -&gt; 2
1, 4 -&gt; 0
1, 5 -&gt; 4
1, 6 -&gt; 0
2, 1 -&gt; 0
2, 2 -&gt; 0
2, 3 -&gt; 2
2, 4 -&gt; 0
2, 5 -&gt; 4
2, 6 -&gt; 0
3, 1 -&gt; 2
3, 2 -&gt; 2
3, 3 -&gt; 4
3, 4 -&gt; 2
3, 5 -&gt; 6
3, 6 -&gt; 2
4, 1 -&gt; 0
4, 2 -&gt; 0
4, 3 -&gt; 2
4, 4 -&gt; 0
4, 5 -&gt; 4
4, 6 -&gt; 0
5, 1 -&gt; 4
5, 2 -&gt; 4
5, 3 -&gt; 6
5, 4 -&gt; 4
5, 5 -&gt; 8
5, 6 -&gt; 4
6, 1 -&gt; 0
6, 2 -&gt; 0
6, 3 -&gt; 2
6, 4 -&gt; 0
6, 5 -&gt; 4
6, 6 -&gt; 0
3, 1, 5 -&gt; 6
4, 5, 2 -&gt; 4
4, 3, 5 -&gt; 6
1, 4, 4 -&gt; 0
5, 5, 2 -&gt; 8
4, 1, 1 -&gt; 0
3, 4, 1 -&gt; 2
4, 3, 5 -&gt; 6
4, 4, 5 -&gt; 4
4, 2, 1 -&gt; 0
3, 5, 5, 2 -&gt; 10
6, 1, 4, 6, 3 -&gt; 2
3, 2, 2, 1, 2, 3 -&gt; 4
3, 6, 1, 2, 5, 2, 5 -&gt; 10


This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!
Python 3, 30 bytes

lambda l:sum(n**3&amp;6for n in l)


Try it online!

(test cases shamelessly borrowed from xnor's answer)

How?

Given \$1\le n\le6\$, the number of petals can be computed with:

$$p=n^{2k+1} \operatorname{and}6,\:k\in\mathbb{N}^*$$

where \$\operatorname{and}\$ is a bitwise operator.

This can also be written as:

$$p=2\times\left\lfloor\frac{n^{2k+1}\bmod 8}{2}\right\rfloor$$

And is based on the fact that, for any \$k\ge1\$:

$$n^{2k+1}\bmod 8=\cases{
n&amp;\text{if $n$ is odd ($1$, $3$ or $5$)}\\
0&amp;\text{if $n$ is even ($2$, $4$ or $6$)}
}$$

More specifically, choosing \$k=1\$:

$$p=n^3 \operatorname{and}6$$

As Python code, the resulting expression is just as long as the nice n%-2%n found by xnor. But because it ends with a digit, we can get rid of the space just before the for, saving a byte.

 n | n**3 | as binary  | AND 6
---+------+------------+-------
 1 |    1 | 00000 00 1 |   0
 2 |    8 | 00001 00 0 |   0
 3 |   27 | 00011 01 1 |   2
 4 |   64 | 01000 00 0 |   0
 5 |  125 | 01111 10 1 |   4
 6 |  216 | 11011 00 0 |   0