MATL, 19 bytes
Oh!5:=s4&\w4:)ghs3>
Input is a numeric row vector where the letters are represented as numbers as follows:
B: 1
L: 2
W: 3
S: 4
O: 5
Output is 1
for truthy, 0
for falsy.
Try it online!: verify all test cases.
###How it works
How it works
- Count ocurrences of each resource.
- Div-mod them by 4.
- Count how many of the remainders for the first four resources (letters
BLWS
) are nonzero. This gives a number c. - Sum the quotients. This gives a number s.
- Output whether c+s ≥ 4.
###Commented code
Commented code
Oh % Append 0 to implicit input. This is just in case inpout is empty
! % Convert into column vector
5: % Push row vector [1 2 3 4 5]
= % Compare for equality, element-wise with broadcast
s % Sum of each column. Gives number of times that each entry of
% [1 2 3 4 5] appears in the input
4&\ % Mod-div 4, element-wise. Pushes vector of remainders and then vector
% of quotients of division by 4
w % Swap. Brings remainders to top
4:) % Get the first four entries
g % Convert to logical. This transforms non-zero values into 1
h % Concatenate with vector of quotients
s % Sum
3> % Does the result exceed 3? Implicitly display