-
Notifications
You must be signed in to change notification settings - Fork 0
/
CF-208A.py
32 lines (24 loc) · 994 Bytes
/
CF-208A.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
remix = input()
remix_length = len(remix)
original_song_words = []
original_song_word = ''
current_letter_index = 0
while current_letter_index < remix_length:
possible_remix_word = remix[current_letter_index] == 'W' and current_letter_index + 2 < remix_length
remix_word_found = False
if possible_remix_word:
word_under_analysis = remix[current_letter_index: current_letter_index + 3]
remix_word_found = word_under_analysis == 'WUB'
if remix_word_found:
if original_song_word != '':
original_song_words.append(original_song_word)
original_song_word = ''
current_letter_index += 2
else:
original_song_word += remix[current_letter_index]
current_letter_index += 1
if original_song_word != '':
original_song_words.append(original_song_word)
original_song_word = ''
for i in range(len(original_song_words)):
print(f' {original_song_words[i]}' if i != 0 else original_song_words[i], end='')