@salamander said in Efficiently parsing a string that can vary in format (C#):
@scholrlea said in Efficiently parsing a string that can vary in format (C#):
This matches the original problem description, but the description itself is bad, as the usable die types for D&D are actually the set {4, 6, 8, 10, 12, 20, 100}.
Those are the physical sizes for dice supported by the rules, but there's also many times where you can use them to just make arbitrary decisions. With physical dice there's usually some kind of grouping or re-roll policy, such as a d2 is equivalent to rolling odds/evens on a d6.
On a computer, I'd see no reason to prevent that.
D&D rules also use d2's and d3's. Without, afaik, detailing how you're supposed to convert other dice to them (possibly because anyone can find solutions after thinking a bit about it). There are 2: division (high/low for d2, 1-2/3-4/5-6 for d3) and modulo (odd/even for d2, 1,4/2,5/3,6 for d3). Both are equally valid, provided you round up in the division. If you need weird dice size because you're dealing with stuff like Mirror Images (and need arbitrary 1 in X probabilities), you need to make sure all outcomes are equally likely by rerolling some results .