Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions matching-brackets/.exercism/config.json

This file was deleted.

1 change: 0 additions & 1 deletion matching-brackets/.exercism/metadata.json

This file was deleted.

130 changes: 0 additions & 130 deletions matching-brackets/HELP.md

This file was deleted.

44 changes: 0 additions & 44 deletions matching-brackets/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions matching-brackets/matching_brackets.py

This file was deleted.

76 changes: 0 additions & 76 deletions matching-brackets/matching_brackets_test.py

This file was deleted.

18 changes: 4 additions & 14 deletions pig-latin/pig_latin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def translate(text: str) -> str:
:return: The text translated to Pig Latin
"""
words: list[str] = text.split(" ")
return " ".join(process_words(word) for word in words)
return " ".join(process_word(word) for word in words)


def process_words(text: str) -> str:
def process_word(text: str) -> str:
"""
Process a single word and convert it to Pig Latin using the four translation rules.

Expand Down Expand Up @@ -54,7 +54,7 @@ def process_words(text: str) -> str:
return f"{text[i:]}{text[:i]}ay"

# Rule 2
if is_consonant(text[0]):
if not is_vowel(text[0]):
# 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.
i = get_consonant_cluster_length(text)
Expand Down Expand Up @@ -106,16 +106,6 @@ def is_vowel(char: str) -> bool:
return char in "aeiou"


def is_consonant(char: str) -> bool:
"""
Check if a character is a consonant (one of the 21 non-vowel letters).

:param char: The character to check
:return: True if the character is a consonant, False otherwise
"""
return char.isalpha() and not is_vowel(char)


def get_consonant_cluster_length(text: str) -> int:
"""
Find the length of the consonant cluster at the beginning of a word.
Expand All @@ -125,7 +115,7 @@ def get_consonant_cluster_length(text: str) -> int:
"""
i = 0
for n, char in enumerate(text):
if is_consonant(char):
if not is_vowel(char):
i = n
else:
break
Expand Down
Loading