Uh oh!
There was an error while loading. Please reload this page.
feat: add pig-latin exercise - #812
Conversation
ahans
left a comment
There was a problem hiding this comment.
Here are my thoughts on your implementation. It certainly passes as a "proof of concept" either way.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
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.
I would vote to move that discussion and possible solutions to an article for the exercise.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
siebenschlaefer
left a comment
There was a problem hiding this comment.
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.