Existing code in test_yacht.zig
for Yacht exercise only tests cases when dice in full-house and four-of-a-kind categories would have groups in certain positions when sorted. For example:
3,3,3,3,5 => four of a kind
3,3,3,5,5 => full house
but there were no tests for these cases
3,5,5,5,5 => four of a kind
3,3,5,5,5 => full house
I.e. the cases where group positions and lengths are switched around and a group with smaller number of elements goes first.
I saw several solutions which were hardcoding checks like
if (sorted[0] == sorted[3]) {
// assume success in detecting four-of a kind
}
which is not correct, because it would fail in the 3,5,5,5,5
case while it shouldn’t.
I have created PR with fixes, but it was auto-closed with suggestion to post here, which is what I did now
The patch itself can be viewed on Github.