I’m making a dice game. There are 5 dice in which I have all the values for and I need to determine if they make up a full house (3 of one and 2 of another), small straight (1-4, 2-6 or 3-6) or a large straight (1-5, 2-6).
Perhaps the best way to approach this seems to be to use regular expressions.
Does anyone know how I would go about representing these rules in regex?
Or if you can provide a better solution, I’d appreciate that.
Examples:
- Full house = 44422 or 11166 or 12212 etc.
- Small Straight = 12342 or 54532 etc.
- Large Straight = 12345 or 52643 etc.
Edit
Changed wording to highlight that this is my inexperienced opinion.
I know how to achieve this using code, but it seems like such a long winded solution, I’m wondering if there’s a more simplistic approach.
Don’t know about c#, but in a scripting language I’d take the regexp route. For each side, calculate how many times it occurs in the combination and join the results together. For example, for the combination
12342the counter string will be121100. Then match the counter string against these patterns: