Skip to content

Commit df87ae3

Browse files
authored
Merge pull request #81 from ikostan/main
Merge from master
2 parents 3732512 + afa9f92 commit df87ae3

File tree

10 files changed

+404
-299
lines changed

10 files changed

+404
-299
lines changed

matching-brackets/.exercism/config.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

matching-brackets/.exercism/metadata.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

matching-brackets/HELP.md

Lines changed: 0 additions & 130 deletions
This file was deleted.

matching-brackets/README.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

matching-brackets/matching_brackets.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

matching-brackets/matching_brackets_test.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

pig-latin/pig_latin.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def translate(text: str) -> str:
1717
:return: The text translated to Pig Latin
1818
"""
1919
words: list[str] = text.split(" ")
20-
return " ".join(process_words(word) for word in words)
20+
return " ".join(process_word(word) for word in words)
2121

2222

23-
def process_words(text: str) -> str:
23+
def process_word(text: str) -> str:
2424
"""
2525
Process a single word and convert it to Pig Latin using the four translation rules.
2626
@@ -54,7 +54,7 @@ def process_words(text: str) -> str:
5454
return f"{text[i:]}{text[:i]}ay"
5555

5656
# Rule 2
57-
if is_consonant(text[0]):
57+
if not is_vowel(text[0]):
5858
# If a word begins with one or more consonants, first move those consonants
5959
# to the end of the word and then add an "ay" sound to the end of the word.
6060
i = get_consonant_cluster_length(text)
@@ -106,16 +106,6 @@ def is_vowel(char: str) -> bool:
106106
return char in "aeiou"
107107

108108

109-
def is_consonant(char: str) -> bool:
110-
"""
111-
Check if a character is a consonant (one of the 21 non-vowel letters).
112-
113-
:param char: The character to check
114-
:return: True if the character is a consonant, False otherwise
115-
"""
116-
return char.isalpha() and not is_vowel(char)
117-
118-
119109
def get_consonant_cluster_length(text: str) -> int:
120110
"""
121111
Find the length of the consonant cluster at the beginning of a word.
@@ -125,7 +115,7 @@ def get_consonant_cluster_length(text: str) -> int:
125115
"""
126116
i = 0
127117
for n, char in enumerate(text):
128-
if is_consonant(char):
118+
if not is_vowel(char):
129119
i = n
130120
else:
131121
break

0 commit comments

Comments
 (0)