728x90
1. Problem: https://py.checkio.org/en/mission/striped-words/
2. My solution
import re
def checkio(line: str) -> int:
text = re.sub(r'[^\w\s]', " ", line)
vowel_list = ["a", "e", "i", "o", "u", "y"]
consonant_list = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "z"]
number_striped_words = 0
for dummy_text in text.split(" "):
if dummy_text.isnumeric(): continue
if len(dummy_text) > 1:
list_dummy_text = list(dummy_text.lower())
for index in range(len(list_dummy_text)):
if list_dummy_text[index].isnumeric() : list_dummy_text[index] = 0
if list_dummy_text[index] in vowel_list: list_dummy_text[index] = 1
if list_dummy_text[index] in consonant_list: list_dummy_text[index] = -1
Striped_words = []
for index in range(len(list_dummy_text) - 1):
Striped_words.append(list_dummy_text[index]*list_dummy_text[index+1])
if (not 1 in Striped_words) and (not 0 in Striped_words): number_striped_words+=1
return number_striped_words
728x90
'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글
[CheckIO/Electronic Station] digits-multiplication (0) | 2024.04.07 |
---|---|
[CheckIO/Scientific-Expedition] Secret Message (0) | 2024.04.07 |
[CheckIO/Scientific Expedition] Beat The Previous (0) | 2024.03.24 |
[CheckIO/Scientific Expedition] Pangram (0) | 2024.03.24 |
[CheckIO][Scientific Expedition] Latest-iso-datetime (0) | 2024.02.18 |
댓글