Pavan
C# PigLatin exercise : tests failing for Rule 3 and Rule 4
I get it now, thanks for the clarification!
Also, I refactored the code to use a foreach loop and go through each word, apply the Pig Latin rules one at a time, and build up the full translated sentence. After making this change, all 23 test cases are passing!
12 replies
C# PigLatin exercise : tests failing for Rule 3 and Rule 4
Thanks for your suggestion! I did as you recommended, and it really helped — now 22 out of 23 test cases are passing.
One test case is still failing with the message below:
Code Run
Assert.Equal("ickquay astfay unray", PigLatin.Translate("quick fast run"));
Test Failure
Assert.Equal() Failure: Strings differ
↓ (pos 3)
Expected: "ickquay astfay unray"
Actual: "ick fast runquay"
↑ (pos 3)
Also, I was wondering do you have any idea why the other test cases were failing before I moved Rule 2 after Rule 4?
12 replies
C# PigLatin exercise : tests failing for Rule 3 and Rule 4
Rule 2: If a word begins with one or more consonants, first move those consonants to the end of the word and then add an "ay" sound to the end of the word.
For example:
"pig" -> "igp" -> "igpay" (starts with single consonant)
"chair" -> "airch" -> "airchay" (starts with multiple consonants)
12 replies