excersises(yacht): add order-independence tests to full-house and four-of-a-kind#354
Conversation
Existing code only tested 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
group with smaller number of elements goes first.
I saw several solutions which were hardcoding checks like
```c
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.
|
Hello. Thanks for opening a PR on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed. That doesn't mean we're not interested in your ideas, or that if you're stuck on something we don't want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use this link to copy this into a new topic there. Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it. |
|
Thanks @dimsuz for the contribution, and for your patience |
|
The conclusion from the forum thread was that we wouldn't merge this. My fault, sorry - I should've mentioned that in this PR. In general, test case additions should be proposed upstream in problem-specifications, and the Zig track should try to minimize the deviation from upstream. A Zig-only test is best reserved for something that is very Zig specific. But all that said, I'm not currently inclined to revert this - it can stay, at least for now. Thanks for the contribution. |
Existing code only tested cases when dice in full-house and four-of-a-kind categories would have groups in certain positions when sorted. For example:
but there were no tests for these cases
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
which is not correct, because it would fail in the
3,5,5,5,5case while it shouldn't.This PR adds a few more tests to check alternative ordering.
Not really sure if the new test case naming is good, a bit too vague, was out of ideas on how to name them correctly while staying compact.