You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your task is to translate text from English to Pig Latin.
4
+
The translation is defined using four rules, which look at the pattern of vowels and consonants at the beginning of a word.
5
+
These rules look at each word's use of vowels and consonants:
6
+
7
+
- vowels: the letters `a`, `e`, `i`, `o`, and `u`
8
+
- consonants: the other 21 letters of the English alphabet
9
+
10
+
## Rule 1
11
+
12
+
If a word begins with a vowel, or starts with `"xr"` or `"yt"`, add an `"ay"` sound to the end of the word.
13
+
14
+
For example:
15
+
16
+
-`"apple"` -> `"appleay"` (starts with vowel)
17
+
-`"xray"` -> `"xrayay"` (starts with `"xr"`)
18
+
-`"yttria"` -> `"yttriaay"` (starts with `"yt"`)
19
+
20
+
## Rule 2
21
+
22
+
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.
23
+
24
+
For example:
25
+
26
+
-`"pig"` -> `"igp"` -> `"igpay"` (starts with single consonant)
27
+
-`"chair"` -> `"airch"` -> `"airchay"` (starts with multiple consonants)
28
+
-`"thrush"` -> `"ushthr"` -> `"ushthray"` (starts with multiple consonants)
29
+
30
+
## Rule 3
31
+
32
+
If a word starts with zero or more consonants followed by `"qu"`, first move those consonants (if any) and the `"qu"` part to the end of the word, and then add an `"ay"` sound to the end of the word.
33
+
34
+
For example:
35
+
36
+
-`"quick"` -> `"ickqu"` -> `"ickquay"` (starts with `"qu"`, no preceding consonants)
37
+
-`"square"` -> `"aresqu"` -> `"aresquay"` (starts with one consonant followed by `"qu`")
38
+
39
+
## Rule 4
40
+
41
+
If a word starts with one or more consonants followed by `"y"`, first move the consonants preceding the `"y"`to the end of the word, and then add an `"ay"` sound to the end of the word.
42
+
43
+
Some examples:
44
+
45
+
-`"my"` -> `"ym"` -> `"ymay"` (starts with single consonant followed by `"y"`)
46
+
-`"rhythm"` -> `"ythmrh"` -> `"ythmrhay"` (starts with multiple consonants followed by `"y"`)
Your parents have challenged you and your sibling to a game of two-on-two basketball.
4
+
Confident they'll win, they let you score the first couple of points, but then start taking over the game.
5
+
Needing a little boost, you start speaking in [Pig Latin][pig-latin], which is a made-up children's language that's difficult for non-children to understand.
6
+
This will give you the edge to prevail over your parents!
"test_code": "expect (\"appleay\" == pigLatin.translate \"apple\")\n |> Test.label \"ay is added to words that start with vowels - word beginning with a\""
5
+
},
6
+
{
7
+
"name": "pigLatin.translate.tests.ex2",
8
+
"test_code": "expect (\"earay\" == pigLatin.translate \"ear\")\n |> Test.label \"ay is added to words that start with vowels - word beginning with e\""
9
+
},
10
+
{
11
+
"name": "pigLatin.translate.tests.ex3",
12
+
"test_code": "expect (\"iglooay\" == pigLatin.translate \"igloo\")\n |> Test.label \"ay is added to words that start with vowels - word beginning with i\""
13
+
},
14
+
{
15
+
"name": "pigLatin.translate.tests.ex4",
16
+
"test_code": "expect (\"objectay\" == pigLatin.translate \"object\")\n |> Test.label \"ay is added to words that start with vowels - word beginning with o\""
17
+
},
18
+
{
19
+
"name": "pigLatin.translate.tests.ex5",
20
+
"test_code": "expect (\"underay\" == pigLatin.translate \"under\")\n |> Test.label \"ay is added to words that start with vowels - word beginning with u\""
21
+
},
22
+
{
23
+
"name": "pigLatin.translate.tests.ex6",
24
+
"test_code": "expect (\"equalay\" == pigLatin.translate \"equal\")\n |> Test.label \"ay is added to words that start with vowels - word beginning with a vowel and followed by a qu\""
25
+
},
26
+
{
27
+
"name": "pigLatin.translate.tests.ex7",
28
+
"test_code": "expect (\"igpay\" == pigLatin.translate \"pig\")\n |> Test.label \"first letter and ay are moved to the end of words that start with consonants - word beginning with p\""
29
+
},
30
+
{
31
+
"name": "pigLatin.translate.tests.ex8",
32
+
"test_code": "expect (\"oalakay\" == pigLatin.translate \"koala\")\n |> Test.label \"first letter and ay are moved to the end of words that start with consonants - word beginning with k\""
33
+
},
34
+
{
35
+
"name": "pigLatin.translate.tests.ex9",
36
+
"test_code": "expect (\"enonxay\" == pigLatin.translate \"xenon\")\n |> Test.label \"first letter and ay are moved to the end of words that start with consonants - word beginning with x\""
37
+
},
38
+
{
39
+
"name": "pigLatin.translate.tests.ex10",
40
+
"test_code": "expect (\"atqay\" == pigLatin.translate \"qat\")\n |> Test.label \"first letter and ay are moved to the end of words that start with consonants - word beginning with q without a following u\""
41
+
},
42
+
{
43
+
"name": "pigLatin.translate.tests.ex11",
44
+
"test_code": "expect (\"airchay\" == pigLatin.translate \"chair\")\n |> Test.label \"some letter clusters are treated like a single consonant - word beginning with ch\""
45
+
},
46
+
{
47
+
"name": "pigLatin.translate.tests.ex12",
48
+
"test_code": "expect (\"eenquay\" == pigLatin.translate \"queen\")\n |> Test.label \"some letter clusters are treated like a single consonant - word beginning with qu\""
49
+
},
50
+
{
51
+
"name": "pigLatin.translate.tests.ex13",
52
+
"test_code": "expect (\"aresquay\" == pigLatin.translate \"square\")\n |> Test.label \"some letter clusters are treated like a single consonant - word beginning with qu and a preceding consonant\""
53
+
},
54
+
{
55
+
"name": "pigLatin.translate.tests.ex14",
56
+
"test_code": "expect (\"erapythay\" == pigLatin.translate \"therapy\")\n |> Test.label \"some letter clusters are treated like a single consonant - word beginning with th\""
57
+
},
58
+
{
59
+
"name": "pigLatin.translate.tests.ex15",
60
+
"test_code": "expect (\"ushthray\" == pigLatin.translate \"thrush\")\n |> Test.label \"some letter clusters are treated like a single consonant - word beginning with thr\""
61
+
},
62
+
{
63
+
"name": "pigLatin.translate.tests.ex16",
64
+
"test_code": "expect (\"oolschay\" == pigLatin.translate \"school\")\n |> Test.label \"some letter clusters are treated like a single consonant - word beginning with sch\""
65
+
},
66
+
{
67
+
"name": "pigLatin.translate.tests.ex17",
68
+
"test_code": "expect (\"yttriaay\" == pigLatin.translate \"yttria\")\n |> Test.label \"some letter clusters are treated like a single vowel - word beginning with yt\""
69
+
},
70
+
{
71
+
"name": "pigLatin.translate.tests.ex18",
72
+
"test_code": "expect (\"xrayay\" == pigLatin.translate \"xray\")\n |> Test.label \"some letter clusters are treated like a single vowel - word beginning with xr\""
73
+
},
74
+
{
75
+
"name": "pigLatin.translate.tests.ex19",
76
+
"test_code": "expect (\"ellowyay\" == pigLatin.translate \"yellow\")\n |> Test.label \"position of y in a word determines if it is a consonant or a vowel - y is treated like a consonant at the beginning of a word\""
77
+
},
78
+
{
79
+
"name": "pigLatin.translate.tests.ex20",
80
+
"test_code": "expect (\"ythmrhay\" == pigLatin.translate \"rhythm\")\n |> Test.label \"position of y in a word determines if it is a consonant or a vowel - y is treated like a vowel at the end of a consonant cluster\""
81
+
},
82
+
{
83
+
"name": "pigLatin.translate.tests.ex21",
84
+
"test_code": "expect (\"ymay\" == pigLatin.translate \"my\")\n |> Test.label \"position of y in a word determines if it is a consonant or a vowel - y as second letter in two letter word\""
85
+
},
86
+
{
87
+
"name": "pigLatin.translate.tests.ex22",
88
+
"test_code": "expect (\"ickquay astfay unray\" == pigLatin.translate \"quick fast run\")\n |> Test.label \"phrases are translated - a whole phrase\""
0 commit comments