Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The order of the results actually matters for the Word Count exercise #931

Closed
elmq0022 opened this issue Dec 4, 2023 · 4 comments
Closed

Comments

@elmq0022
Copy link
Contributor

elmq0022 commented Dec 4, 2023

The instructions state that the order of the unique words does not matter when in fact they do.

https://github.com/exercism/c/blob/main/exercises/practice/word-count/.docs/instructions.md?plain=1#L21

The tests assume the word order is the order they are first encountered in.

Either the instructions should be updated, or the expected and actual results could just be sorted before the check to ensure a standard order of comparison. Personally, I would prefer the later option, and I could do some work in the future to make that happen if people are interested.

@wolf99
Copy link
Contributor

wolf99 commented Dec 4, 2023

Can confirm that the check function the tests use has a simple loop that implicitly expects the same order the expected output is given in.

https://github.com/exercism/c/blob/main/exercises%2Fpractice%2Fword-count%2Ftest_word_count.c#L29

Option could either be to sort both the result and expected results to some same ordering, or just to improve this loop to not expect any order.

@elmq0022
Copy link
Contributor Author

elmq0022 commented Dec 5, 2023

I can update the tests to use the stdlib qsort. We just need a custom sort function for the struct with text/string and number of occurrences. That shouldn't be too bad to implement. TBH I just wanted to see some traction on the issue before doing the work. I'll try to open a PR tonight.

@elmq0022
Copy link
Contributor Author

Sorry about the delay. I'll try to look at any feedback on #932 as soon as possible. Thankfully this is a rather small PR.

@elmq0022
Copy link
Contributor Author

closed by #932

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

No branches or pull requests

2 participants