-
-
Notifications
You must be signed in to change notification settings - Fork 230
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
feat: add pig-latin exercise #812
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.
Here are my thoughts on your implementation. It certainly passes as a "proof of concept" either way.
for (std::string start : {"a", "e", "i", "o", "u", "yt", "xr"}) { | ||
if (word.substr(0, start.size()) == start) return word + "ay"; | ||
} | ||
for (std::string start : {"thr", "sch", "squ", "ch", "qu", "th", "rh"}) { |
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.
While this list of consonant clusters is sufficient to pass the tests, those cover only a fraction of the possibilities. Words for which the current implementation would not give the correct pig latin version include "friend", "splash", "smile", "string".
That's why I said in some other comment that my implementation is more generic. Instead of explicitly listing consonant clusters, it moves characters to the back until it finds a vowel. Only qu
needs special handling in that case.
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 would vote to move that discussion and possible solutions to an article for the 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.
Looks good!
Solid example solution. There might be a few small details that could be improved (e.g. passing std::string
by reference to const
or calling phrase.substr(start)
or some of the things from @ahans' comments) but nothing that would disqualify this as an example solution or block this PR from being merged.
No description provided.