-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Wrong ENUMS in Allergies #142
Comments
Hi, I can see why you'd think this is a bug, however it's actually not. I'll try to explain. The exercise it taken from https://github.com/exercism/problem-specifications/blob/main/exercises/allergies/canonical-data.json where we can see that each test case takes an The The values for the items in the description (https://github.com/exercism/problem-specifications/blob/main/exercises/allergies/description.md) does not correspond to the enum values, but are instead just used to test if a person is allergic to a specific item or not. So if we pass the enum value for PEANUTS and the score of 2, we would get If you think about it, it's actually a bit field, where different bits mark different allgeries. I hope this makes sense, I would also like to add that this is how other languages do it as well, e.g. C and C#. See: Let me know if anything is unclear, or if you have any further questions! |
Using bitfields is exactly what I've seen in many tracks. This comment is merely to support this implementation. Powers of two encoded in a single number are (usually) bit flags in a bit field :) |
Thanks for your quick reply! I completely understand your point and know how bitfields work and what is meant to be the exercise. However, I have a mentee trying to solve this and she says that the values in the corresponding C file are not defined as specified in the readme. And I have to say that she is right. I think that either we have to adapt the tests to show that the ENUMS values are used to shift bits into place instead of ASSERTING with "magic" numbers OR adapt the readme/specification stating this. I think that everyone agrees that the exercise is not to find out what could be meant but working with bitfields in assembler instead. |
Hm, maybe I'm wrong, the C# example solution actually uses the values in the specifications for the enum: https://github.com/exercism/csharp/blob/main/exercises/practice/allergies/.meta/Example.cs |
FYI The allergies exercise is currently causing the build to fail: https://github.com/exercism/x86-64-assembly/runs/4321821043?check_suite_focus=true |
I think there is a bug in https://exercism.org/tracks/x86-64-assembly/exercises/allergies - the README states that the values defined in the enum are powers of 2, but the C file that tests against is not defining them as such. They are defined sequentially.
The text was updated successfully, but these errors were encountered: