26
1
You are given four integers: \$e,s,b\in\{0,1\}\$ and \$S\in \{0,1,2,4\}\$, where \$e,s,b,S\$ stand for egg, sausage, bacon and spam respectively.
Your task is to figure out whether the corresponding ingredients match a valid entry in the following menu:
[e]gg | [s]ausage | [b]acon | [S]pam
-------+-----------+---------+--------
1 | 0 | 1 | 0
1 | 1 | 1 | 0
1 | 0 | 0 | 1
1 | 0 | 1 | 1
1 | 1 | 1 | 1
0 | 1 | 1 | 2
1 | 0 | 1 | 4
1 | 0 | 0 | 4
1 | 1 | 0 | 2
This is a subset of the menu described in the famous Monty Python's sketch, where dishes based on other ingredients are omitted.
Rules
You can take \$(e,s,b,S)\$ in any order and any convenient format as long as they are clearly separated into 4 distinct values as described above (e.g. claiming that your code takes a single bitmask with all values packed in there is not allowed).
Examples:
[1,0,1,4]
,"1014"
, or 4 distinct argumentsEach value is guaranteed to be valid (i.e. you don't have to support \$e=2\$ or \$S=3\$).
- You may return (or print) either:
- a truthy value for matching and a falsy value for not-matching
- a falsy value for matching and a truthy value for not-matching
- 2 distinct, consistent values of your choice (please specify them in your answer)
- This is code-golf
Test cases (all of them)
Format: [e, s, b, S] --> matching
[ 0, 0, 0, 0 ] --> false
[ 0, 0, 0, 1 ] --> false
[ 0, 0, 0, 2 ] --> false
[ 0, 0, 0, 4 ] --> false
[ 0, 0, 1, 0 ] --> false
[ 0, 0, 1, 1 ] --> false
[ 0, 0, 1, 2 ] --> false
[ 0, 0, 1, 4 ] --> false
[ 0, 1, 0, 0 ] --> false
[ 0, 1, 0, 1 ] --> false
[ 0, 1, 0, 2 ] --> false
[ 0, 1, 0, 4 ] --> false
[ 0, 1, 1, 0 ] --> false
[ 0, 1, 1, 1 ] --> false
[ 0, 1, 1, 2 ] --> true
[ 0, 1, 1, 4 ] --> false
[ 1, 0, 0, 0 ] --> false
[ 1, 0, 0, 1 ] --> true
[ 1, 0, 0, 2 ] --> false
[ 1, 0, 0, 4 ] --> true
[ 1, 0, 1, 0 ] --> true
[ 1, 0, 1, 1 ] --> true
[ 1, 0, 1, 2 ] --> false
[ 1, 0, 1, 4 ] --> true
[ 1, 1, 0, 0 ] --> false
[ 1, 1, 0, 1 ] --> false
[ 1, 1, 0, 2 ] --> true
[ 1, 1, 0, 4 ] --> false
[ 1, 1, 1, 0 ] --> true
[ 1, 1, 1, 1 ] --> true
[ 1, 1, 1, 2 ] --> false
[ 1, 1, 1, 4 ] --> false
Spam spam spam spam. Lovely spam! Wonderful spam!
Can we take input as a string like "4101", or does that fail the "clearly separated" rule? – Grimmy – 2020-02-17T15:12:51.463
2@Grimmy I assume that it stands for
"Sesb"
, which is fine. – Arnauld – 2020-02-17T15:18:29.0801The new title is much better – RGS – 2020-02-17T18:22:02.827
Bloody vikings... – corsiKa – 2020-02-19T23:05:23.287
May we take a decimal representation of the four values (e.g.
[ 0, 1, 1, 2 ]
as112
)? – Jonathan Allan – 2020-02-22T20:15:17.770@JonathanAllan I'd say no because that's not really 4 distinct values anymore (whereas a string is OK because it's made of 4 distinct characters). – Arnauld – 2020-02-22T20:24:36.357