-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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; |
There was a problem hiding this comment.
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) ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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);
Feel free to criticize anything, big or small.