Skip to content

Commit

Permalink
rule 1 with single letter words
Browse files Browse the repository at this point in the history
  • Loading branch information
keiravillekode committed Jun 5, 2024
1 parent 9d0f370 commit d0ba751
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions exercises/practice/pig-latin/.meta/example.v
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ fn translate(phrase string) string {
mut builder := strings.new_builder(phrase.len + 2 * words.len)
for word in words {
mut index := 0
rule1 := word.len > 1 && if vowel[word[0] - `a`] { word[0] != `y`
|| word[0..2] == 'yt' } else { word[0..2] == 'xr' }
rule1 := if vowel[word[0] - `a`] {
word[0] != `y` || (word.len > 1 && word[0..2] == 'yt')
} else {
word.len > 1 && word[0..2] == 'xr'
}

if !rule1 {
index++
Expand Down

0 comments on commit d0ba751

Please sign in to comment.