In The Settlers of Catan board game, there are five resource types: Brick, Log, Ore, Wheat, and Sheep. Building a settlement costs a Brick, a Log, a Wheat, and a Sheep. However, you can also trade in four identical resources to get a resource of a different type. For instance, if you had four ores in your hand, you could trade all of them in and get one sheep.
Your job is to determine whether or not I can build a settlement, given my hand.
Input will be a sequence of the letters
S, taken in any reasonable format. These letters correspond to the five resource types given above. You should output whether or not I have the resources necessary to build a settlement, taking into account the possibility of trading four of a kind.
This is code-golf, so shortest code in bytes wins.
- You do not have to output what trades I need to perform or how many settlements I could build. A simple "yes" or "no" will do.
- You may not assume that the input is in any specific order. In particular, you may not assume that resources of the same type are grouped together, so
OBLSOis a valid input.
- This is decision-problem, so you may use any value you want to mean "yes" and "no", as long as the two chosen values are distinct and consistent.
- The only rules we're concerned with here are the ones listed above. More complicated Settlers of Catan rules like trading with other players or at harbours are not relevant here.
- The input characters (
S) can be substituted with other values if it is easier for your particular language of choice, so long as there are five distinct inputs. If you use other input values, please specify them in your answer.
BLWS -> Yes OOOOWLB -> Yes (trade four O for a S) OOW -> No BBBO -> No (empty input) -> No BBBBLW -> No BBBBBLW -> Yes (trade four B for a S) OOOOOOOOOOOOOOOO -> Yes (sixteen O; trade for B, L, W, S) BLBLBLBLBL -> Yes (trade L for W and B for S) BLSWBLSWBLSW -> Yes (extra, unused resources are ignored)