05AB1E, 19 bytes
0 -> Ore
1 -> Brick
2 -> Log
3 -> Wheat
4 -> Sheep
Returns 0 when false, and 1 otherwise.
{γvyDĀi¼¨}g4÷}¾)O3›
Explanation:
{γvyDĀi¼¨}g4÷}¾)O3› Implicit input, e.g. 0030201
{ Sort -> 0000123
γ Split into chunks of consecutive elements: [0000, 1, 2, 3]
vy For each chunk...
DĀ ...is different than 0?
i¼¨} ...if true: increment the counter by 1, and
remove 1 element from the chunk
g4÷ ...divide the number of elements by 4
} End For
¾ Push the counter
) Wrap the entire stack in a list
O Sum of that list
3> True if > 3
Implicit output
AlternativeNon-competive solution: 17 bytes
Works well except for empty inputs. I think that there isThere was a problembug in 05AB1E with the operator «
when the input is emptyI first submitted that solution, subsequent operands likewhere some operators badly handled empty inputs. This resulted in this solution answering γ1
give inconsistent resultson an empty input. Does anyone
This has a workaround? (same thing goes for ì
)now been fixed, so this solution works just fine.
The difference here is that we add an ore prior to removing one of each resource, indiscriminately, counting the number of resources removed that way. We then decrement the counter by 1 to get the correct number of B, L, W and S.
0«{γε¨g4÷¼}O¾<+3›