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

add exercise zebra-puzzle #959

Merged
merged 5 commits into from
Feb 25, 2024

Conversation

siebenschlaefer
Copy link
Contributor

Feel free to criticize anything, big or small.

@siebenschlaefer siebenschlaefer mentioned this pull request Feb 25, 2024
12 tasks
config.json Outdated Show resolved Hide resolved
Copy link
Member

@ryanplusplus ryanplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really slick! This is my first time seeing a solution to this exercise.

@ryanplusplus ryanplusplus merged commit 1f13e2c into exercism:main Feb 25, 2024
4 checks passed
Copy link
Contributor

@wolf99 wolf99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like there may be some way to implement a large part of this with x macros. But I can't see it well enough on mobile to know for sure

break;
case NORWEGIAN:
*out_owns_zebra = "Norwegian";
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why solve the same problem twice?
Is it possible to solve it once and then just query the results (possibly in some generic way) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to take an object oriented approach to the exercise where solving and querying the solution are separate steps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, and don't like it either.
I was under the impression that these two separate functions would be a what the author of the problem-specification intended, with the two "properties" drinksWater and ownsZebra.
I looked at the C# version where those are two static methods and the Python version where those are two free functions.

But now that you asked I dug a little further and found the Go version that has a single function SolvePuzzle() which I like more.

I could change the code to something like

struct solution
{
   const char *drinks_water;
   const char *owns_zebra;
};

struct solution solve_puzzle(void);

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