Skip to content

excersises(yacht): add order-independence tests to full-house and four-of-a-kind#354

Merged
booniepepper merged 2 commits into
exercism:mainfrom
dimsuz:dimsuz-add-yacht-tests
Nov 22, 2023
Merged

excersises(yacht): add order-independence tests to full-house and four-of-a-kind#354
booniepepper merged 2 commits into
exercism:mainfrom
dimsuz:dimsuz-add-yacht-tests

Conversation

@dimsuz

@dimsuz dimsuz commented Oct 8, 2023

Copy link
Copy Markdown
Contributor

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 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.

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.

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.
@github-actions

github-actions Bot commented Oct 8, 2023

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot closed this Oct 8, 2023
@booniepepper booniepepper reopened this Nov 22, 2023
@booniepepper

Copy link
Copy Markdown
Contributor

Thanks @dimsuz for the contribution, and for your patience

@booniepepper booniepepper merged commit 5b439e7 into exercism:main Nov 22, 2023
@ee7

ee7 commented Nov 30, 2023

Copy link
Copy Markdown
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants