Домашни > Man who speaks the ends of words > Решения > Решението на Адем Црънчалиев

Резултати
9 точки от тестове
0 точки от учител

9 точки общо

11 успешни теста
1 неуспешни теста
Код

 1def beginning(word):
 2    word_length = len(word)
 3    value_remaining = word_length % 3
 4
 5    if value_remaining == 0:
 6        word_length_to_take = int(word_length / 3)
 7        return (word[0:word_length_to_take])
 8    elif value_remaining == 1:
 9        word_length_to_take = int(((word_length)-1) / 3)
10        return (word[0:word_length_to_take])
11    else:
12        word_length_to_take = 0
13        if (word_length - 1) % 2 == 0:
14            word_length_to_take = int((word_length - 1) / 2)
15        else:
16            word_length_to_take = int((word_length - 2) / 2)
17
18        return word[0:word_length_to_take]
19
20def end(word):
21    word_length = len(word)
22    value_remaining = word_length % 3
23
24    if value_remaining == 0:
25        word_length_to_take = int(word_length / 3)
26        return word[word_length - word_length_to_take : word_length]
27    elif value_remaining == 1:
28        word_length_to_take = int(((word_length)-1) / 3)
29        return word[word_length - word_length_to_take : word_length]
30    else:
31        word_length_to_take = 0
32        if (word_length - 1) % 2 == 0:
33            word_length_to_take = int((word_length - 1) / 2)
34        else:
35            word_length_to_take = int((word_length - 2) / 2)
36
37        return word[word_length - word_length_to_take : word_length]
38
39def middle(word):
40    word_length = len(word)
41    value_remaining = word_length % 3
42
43    if value_remaining == 0:
44        word_length_to_take = int(word_length / 3)
45        return (word[word_length_to_take : word_length - word_length_to_take])
46    elif value_remaining == 1:
47        word_length_to_take = int(((word_length)-1) / 3)
48        return (word[word_length_to_take  : word_length - word_length_to_take])
49    else:
50        word_length_to_take = 0
51        if (word_length - 1) % 2 == 0:
52            word_length_to_take = int((word_length - 1) / 2)
53        else:
54            word_length_to_take = int((word_length - 2) / 2)
55
56        return word[word_length_to_take : word_length - word_length_to_take]
57
58def split_sentence(sentece):
59    splited_sentence = sentece.split(' ')
60    result = []
61    for word in splited_sentence:
62        beginning_of_word = beginning(word)
63        middle_of_word = middle(word)
64        end_of_word = end(word)
65        result.append((beginning_of_word,middle_of_word,end_of_word))
66    
67    return result
68
69print(split_sentence('Продаваме лиофилизиран ананас'))

[('Про', 'дав', 'аме'), ('лиоф', 'илиз', 'иран'), ('ан', 'ан', 'ас')]
.F..........
======================================================================
FAIL: test_mixed_sentence (test.TestSentence)
Test with mixed remainder input.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 75, in test_mixed_sentence
self.assertEqual(split_sentence('Здравейте момчета къде ми е отвертката'),
AssertionError: Lists differ: [('Зд[49 chars]', 'е'), ('', 'ми', ''), ('', 'е', ''), ('отв', 'ертк', 'ата')] != [('Зд[49 chars]', 'е'), ('м', '', 'и'), ('', 'е', ''), ('отв', 'ертк', 'ата')]

First differing element 3:
('', 'ми', '')
('м', '', 'и')

[('Здр', 'аве', 'йте'),
('мо', 'мче', 'та'),
('к', 'ъд', 'е'),
- ('', 'ми', ''),
+ ('м', '', 'и'),
('', 'е', ''),
('отв', 'ертк', 'ата')]

----------------------------------------------------------------------
Ran 12 tests in 0.001s

FAILED (failures=1)

Дискусия
Адем Црънчалиев
17.10.2023 10:12

Когато премахна от [0:length] 0-лата, не ми връща правилен резултат.
Виктор Бечев
17.10.2023 09:30

Две генерални забележки: - Навсякъде си написал "lenght", думата е "length". - Всичките условия и изчисления правят "алгоритъма" доста трудно-проследим. Вероятно ще сработи, не държа да го променяш с риск да стане по-неработещо, просто FYI.
История

f1def beginning(word):f1def beginning(word):
2    word_length = len(word)2    word_length = len(word)
3    value_remaining = word_length % 33    value_remaining = word_length % 3
44
5    if value_remaining == 0:5    if value_remaining == 0:
6        word_length_to_take = int(word_length / 3)6        word_length_to_take = int(word_length / 3)
n7        return (word[word_length_to_take])n7        return (word[0:word_length_to_take])
8    elif value_remaining == 1:8    elif value_remaining == 1:
9        word_length_to_take = int(((word_length)-1) / 3)9        word_length_to_take = int(((word_length)-1) / 3)
n10        return (word[word_length_to_take])n10        return (word[0:word_length_to_take])
11    else:11    else:
12        word_length_to_take = 012        word_length_to_take = 0
13        if (word_length - 1) % 2 == 0:13        if (word_length - 1) % 2 == 0:
14            word_length_to_take = int((word_length - 1) / 2)14            word_length_to_take = int((word_length - 1) / 2)
15        else:15        else:
16            word_length_to_take = int((word_length - 2) / 2)16            word_length_to_take = int((word_length - 2) / 2)
1717
n18        return word[word_length_to_take]n18        return word[0:word_length_to_take]
1919
20def end(word):20def end(word):
21    word_length = len(word)21    word_length = len(word)
22    value_remaining = word_length % 322    value_remaining = word_length % 3
2323
24    if value_remaining == 0:24    if value_remaining == 0:
25        word_length_to_take = int(word_length / 3)25        word_length_to_take = int(word_length / 3)
26        return word[word_length - word_length_to_take : word_length]26        return word[word_length - word_length_to_take : word_length]
27    elif value_remaining == 1:27    elif value_remaining == 1:
28        word_length_to_take = int(((word_length)-1) / 3)28        word_length_to_take = int(((word_length)-1) / 3)
29        return word[word_length - word_length_to_take : word_length]29        return word[word_length - word_length_to_take : word_length]
30    else:30    else:
31        word_length_to_take = 031        word_length_to_take = 0
32        if (word_length - 1) % 2 == 0:32        if (word_length - 1) % 2 == 0:
33            word_length_to_take = int((word_length - 1) / 2)33            word_length_to_take = int((word_length - 1) / 2)
34        else:34        else:
35            word_length_to_take = int((word_length - 2) / 2)35            word_length_to_take = int((word_length - 2) / 2)
3636
37        return word[word_length - word_length_to_take : word_length]37        return word[word_length - word_length_to_take : word_length]
3838
39def middle(word):39def middle(word):
40    word_length = len(word)40    word_length = len(word)
41    value_remaining = word_length % 341    value_remaining = word_length % 3
4242
43    if value_remaining == 0:43    if value_remaining == 0:
44        word_length_to_take = int(word_length / 3)44        word_length_to_take = int(word_length / 3)
45        return (word[word_length_to_take : word_length - word_length_to_take])45        return (word[word_length_to_take : word_length - word_length_to_take])
46    elif value_remaining == 1:46    elif value_remaining == 1:
47        word_length_to_take = int(((word_length)-1) / 3)47        word_length_to_take = int(((word_length)-1) / 3)
48        return (word[word_length_to_take  : word_length - word_length_to_take])48        return (word[word_length_to_take  : word_length - word_length_to_take])
49    else:49    else:
50        word_length_to_take = 050        word_length_to_take = 0
51        if (word_length - 1) % 2 == 0:51        if (word_length - 1) % 2 == 0:
52            word_length_to_take = int((word_length - 1) / 2)52            word_length_to_take = int((word_length - 1) / 2)
53        else:53        else:
54            word_length_to_take = int((word_length - 2) / 2)54            word_length_to_take = int((word_length - 2) / 2)
5555
56        return word[word_length_to_take : word_length - word_length_to_take]56        return word[word_length_to_take : word_length - word_length_to_take]
5757
58def split_sentence(sentece):58def split_sentence(sentece):
n59    splited_sentence = sentece.split()n59    splited_sentence = sentece.split(' ')
60    result = []60    result = []
61    for word in splited_sentence:61    for word in splited_sentence:
62        beginning_of_word = beginning(word)62        beginning_of_word = beginning(word)
63        middle_of_word = middle(word)63        middle_of_word = middle(word)
64        end_of_word = end(word)64        end_of_word = end(word)
65        result.append((beginning_of_word,middle_of_word,end_of_word))65        result.append((beginning_of_word,middle_of_word,end_of_word))
66    66    
67    return result67    return result
6868
tt69print(split_sentence('Продаваме лиофилизиран ананас'))
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1def beginning(word):f1def beginning(word):
n2    wordLenght = len(word)n2    word_length = len(word)
3    valueRemaining = wordLenght % 33    value_remaining = word_length % 3
44
n5    if valueRemaining == 0:n5    if value_remaining == 0:
6        wordLenghtToTake = int(wordLenght / 3)6        word_length_to_take = int(word_length / 3)
7        return (word[0:wordLenghtToTake])7        return (word[word_length_to_take])
8    elif valueRemaining == 1:8    elif value_remaining == 1:
9        wordLenghtToTake = int(((wordLenght)-1) / 3)9        word_length_to_take = int(((word_length)-1) / 3)
10        return (word[0:wordLenghtToTake])10        return (word[word_length_to_take])
11    else:11    else:
n12        wordLenghtToTake = 0n12        word_length_to_take = 0
13        if (wordLenght - 1) % 2 == 0:13        if (word_length - 1) % 2 == 0:
14            wordLenghtToTake = int((wordLenght - 1) / 2)14            word_length_to_take = int((word_length - 1) / 2)
15        else:15        else:
n16            wordLenghtToTake = int((wordLenght - 2) / 2)n16            word_length_to_take = int((word_length - 2) / 2)
1717
n18        return (word[0:wordLenghtToTake])n18        return word[word_length_to_take]
1919
20def end(word):20def end(word):
n21    wordLenght = len(word)n21    word_length = len(word)
22    valueRemaining = wordLenght % 322    value_remaining = word_length % 3
2323
n24    if valueRemaining == 0:n24    if value_remaining == 0:
25        wordLenghtToTake = int(wordLenght / 3)25        word_length_to_take = int(word_length / 3)
26        return (word[wordLenght - wordLenghtToTake : wordLenght])26        return word[word_length - word_length_to_take : word_length]
27    elif valueRemaining == 1:27    elif value_remaining == 1:
28        wordLenghtToTake = int(((wordLenght)-1) / 3)28        word_length_to_take = int(((word_length)-1) / 3)
29        return (word[wordLenght - wordLenghtToTake : wordLenght])29        return word[word_length - word_length_to_take : word_length]
30    else:30    else:
n31        wordLenghtToTake = 0n31        word_length_to_take = 0
32        if (wordLenght - 1) % 2 == 0:32        if (word_length - 1) % 2 == 0:
33            wordLenghtToTake = int((wordLenght - 1) / 2)33            word_length_to_take = int((word_length - 1) / 2)
34        else:34        else:
n35            wordLenghtToTake = int((wordLenght - 2) / 2)n35            word_length_to_take = int((word_length - 2) / 2)
3636
n37        return (word[wordLenght - wordLenghtToTake : wordLenght])n37        return word[word_length - word_length_to_take : word_length]
3838
39def middle(word):39def middle(word):
n40    wordLenght = len(word)n40    word_length = len(word)
41    valueRemaining = wordLenght % 341    value_remaining = word_length % 3
4242
n43    if valueRemaining == 0:n43    if value_remaining == 0:
44        wordLenghtToTake = int(wordLenght / 3)44        word_length_to_take = int(word_length / 3)
45        return (word[wordLenghtToTake : wordLenght - wordLenghtToTake])45        return (word[word_length_to_take : word_length - word_length_to_take])
46    elif valueRemaining == 1:46    elif value_remaining == 1:
47        wordLenghtToTake = int(((wordLenght)-1) / 3)47        word_length_to_take = int(((word_length)-1) / 3)
48        return (word[wordLenghtToTake  : wordLenght - wordLenghtToTake])48        return (word[word_length_to_take  : word_length - word_length_to_take])
49    else:49    else:
n50        wordLenghtToTake = 0n50        word_length_to_take = 0
51        if (wordLenght - 1) % 2 == 0:51        if (word_length - 1) % 2 == 0:
52            wordLenghtToTake = int((wordLenght - 1) / 2)52            word_length_to_take = int((word_length - 1) / 2)
53        else:53        else:
n54            wordLenghtToTake = int((wordLenght - 2) / 2)n54            word_length_to_take = int((word_length - 2) / 2)
5555
n56        return (word[wordLenghtToTake : wordLenght - wordLenghtToTake])n56        return word[word_length_to_take : word_length - word_length_to_take]
5757
58def split_sentence(sentece):58def split_sentence(sentece):
n59    splitedSentence = sentece.split(' ')n59    splited_sentence = sentece.split()
60    result = []60    result = []
n61    for word in splitedSentence:n61    for word in splited_sentence:
62        beginningOfWord = beginning(word)62        beginning_of_word = beginning(word)
63        middleOfWord = middle(word)63        middle_of_word = middle(word)
64        endOfWord = end(word)64        end_of_word = end(word)
65        result.append((beginningOfWord,middleOfWord,endOfWord))65        result.append((beginning_of_word,middle_of_word,end_of_word))
66    66    
t67    return (result)t67    return result
6868
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1def beginning(word):f1def beginning(word):
2    wordLenght = len(word)2    wordLenght = len(word)
3    valueRemaining = wordLenght % 33    valueRemaining = wordLenght % 3
44
5    if valueRemaining == 0:5    if valueRemaining == 0:
6        wordLenghtToTake = int(wordLenght / 3)6        wordLenghtToTake = int(wordLenght / 3)
7        return (word[0:wordLenghtToTake])7        return (word[0:wordLenghtToTake])
8    elif valueRemaining == 1:8    elif valueRemaining == 1:
9        wordLenghtToTake = int(((wordLenght)-1) / 3)9        wordLenghtToTake = int(((wordLenght)-1) / 3)
10        return (word[0:wordLenghtToTake])10        return (word[0:wordLenghtToTake])
11    else:11    else:
12        wordLenghtToTake = 012        wordLenghtToTake = 0
13        if (wordLenght - 1) % 2 == 0:13        if (wordLenght - 1) % 2 == 0:
14            wordLenghtToTake = int((wordLenght - 1) / 2)14            wordLenghtToTake = int((wordLenght - 1) / 2)
15        else:15        else:
16            wordLenghtToTake = int((wordLenght - 2) / 2)16            wordLenghtToTake = int((wordLenght - 2) / 2)
1717
18        return (word[0:wordLenghtToTake])18        return (word[0:wordLenghtToTake])
1919
20def end(word):20def end(word):
21    wordLenght = len(word)21    wordLenght = len(word)
22    valueRemaining = wordLenght % 322    valueRemaining = wordLenght % 3
2323
24    if valueRemaining == 0:24    if valueRemaining == 0:
25        wordLenghtToTake = int(wordLenght / 3)25        wordLenghtToTake = int(wordLenght / 3)
26        return (word[wordLenght - wordLenghtToTake : wordLenght])26        return (word[wordLenght - wordLenghtToTake : wordLenght])
27    elif valueRemaining == 1:27    elif valueRemaining == 1:
28        wordLenghtToTake = int(((wordLenght)-1) / 3)28        wordLenghtToTake = int(((wordLenght)-1) / 3)
29        return (word[wordLenght - wordLenghtToTake : wordLenght])29        return (word[wordLenght - wordLenghtToTake : wordLenght])
30    else:30    else:
31        wordLenghtToTake = 031        wordLenghtToTake = 0
32        if (wordLenght - 1) % 2 == 0:32        if (wordLenght - 1) % 2 == 0:
33            wordLenghtToTake = int((wordLenght - 1) / 2)33            wordLenghtToTake = int((wordLenght - 1) / 2)
34        else:34        else:
35            wordLenghtToTake = int((wordLenght - 2) / 2)35            wordLenghtToTake = int((wordLenght - 2) / 2)
3636
37        return (word[wordLenght - wordLenghtToTake : wordLenght])37        return (word[wordLenght - wordLenghtToTake : wordLenght])
3838
39def middle(word):39def middle(word):
40    wordLenght = len(word)40    wordLenght = len(word)
41    valueRemaining = wordLenght % 341    valueRemaining = wordLenght % 3
4242
43    if valueRemaining == 0:43    if valueRemaining == 0:
44        wordLenghtToTake = int(wordLenght / 3)44        wordLenghtToTake = int(wordLenght / 3)
45        return (word[wordLenghtToTake : wordLenght - wordLenghtToTake])45        return (word[wordLenghtToTake : wordLenght - wordLenghtToTake])
46    elif valueRemaining == 1:46    elif valueRemaining == 1:
47        wordLenghtToTake = int(((wordLenght)-1) / 3)47        wordLenghtToTake = int(((wordLenght)-1) / 3)
48        return (word[wordLenghtToTake  : wordLenght - wordLenghtToTake])48        return (word[wordLenghtToTake  : wordLenght - wordLenghtToTake])
49    else:49    else:
50        wordLenghtToTake = 050        wordLenghtToTake = 0
51        if (wordLenght - 1) % 2 == 0:51        if (wordLenght - 1) % 2 == 0:
52            wordLenghtToTake = int((wordLenght - 1) / 2)52            wordLenghtToTake = int((wordLenght - 1) / 2)
53        else:53        else:
54            wordLenghtToTake = int((wordLenght - 2) / 2)54            wordLenghtToTake = int((wordLenght - 2) / 2)
5555
56        return (word[wordLenghtToTake : wordLenght - wordLenghtToTake])56        return (word[wordLenghtToTake : wordLenght - wordLenghtToTake])
5757
58def split_sentence(sentece):58def split_sentence(sentece):
59    splitedSentence = sentece.split(' ')59    splitedSentence = sentece.split(' ')
60    result = []60    result = []
61    for word in splitedSentence:61    for word in splitedSentence:
62        beginningOfWord = beginning(word)62        beginningOfWord = beginning(word)
63        middleOfWord = middle(word)63        middleOfWord = middle(word)
64        endOfWord = end(word)64        endOfWord = end(word)
65        result.append((beginningOfWord,middleOfWord,endOfWord))65        result.append((beginningOfWord,middleOfWord,endOfWord))
66    66    
t67    print(result)t67    return (result)
6868
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1def beginning(word):f1def beginning(word):
2    wordLenght = len(word)2    wordLenght = len(word)
3    valueRemaining = wordLenght % 33    valueRemaining = wordLenght % 3
44
5    if valueRemaining == 0:5    if valueRemaining == 0:
6        wordLenghtToTake = int(wordLenght / 3)6        wordLenghtToTake = int(wordLenght / 3)
n7        print(word[0:wordLenghtToTake])n7        return (word[0:wordLenghtToTake])
8    elif valueRemaining == 1:8    elif valueRemaining == 1:
9        wordLenghtToTake = int(((wordLenght)-1) / 3)9        wordLenghtToTake = int(((wordLenght)-1) / 3)
n10        print(word[0:wordLenghtToTake])n10        return (word[0:wordLenghtToTake])
11    else:11    else:
12        wordLenghtToTake = 012        wordLenghtToTake = 0
13        if (wordLenght - 1) % 2 == 0:13        if (wordLenght - 1) % 2 == 0:
14            wordLenghtToTake = int((wordLenght - 1) / 2)14            wordLenghtToTake = int((wordLenght - 1) / 2)
15        else:15        else:
16            wordLenghtToTake = int((wordLenght - 2) / 2)16            wordLenghtToTake = int((wordLenght - 2) / 2)
1717
n18        print(word[0:wordLenghtToTake])n18        return (word[0:wordLenghtToTake])
1919
20def end(word):20def end(word):
21    wordLenght = len(word)21    wordLenght = len(word)
22    valueRemaining = wordLenght % 322    valueRemaining = wordLenght % 3
2323
24    if valueRemaining == 0:24    if valueRemaining == 0:
25        wordLenghtToTake = int(wordLenght / 3)25        wordLenghtToTake = int(wordLenght / 3)
n26        print(word[wordLenght - wordLenghtToTake : wordLenght])n26        return (word[wordLenght - wordLenghtToTake : wordLenght])
27    elif valueRemaining == 1:27    elif valueRemaining == 1:
28        wordLenghtToTake = int(((wordLenght)-1) / 3)28        wordLenghtToTake = int(((wordLenght)-1) / 3)
n29        print(word[wordLenght - wordLenghtToTake : wordLenght])n29        return (word[wordLenght - wordLenghtToTake : wordLenght])
30    else:30    else:
31        wordLenghtToTake = 031        wordLenghtToTake = 0
32        if (wordLenght - 1) % 2 == 0:32        if (wordLenght - 1) % 2 == 0:
33            wordLenghtToTake = int((wordLenght - 1) / 2)33            wordLenghtToTake = int((wordLenght - 1) / 2)
34        else:34        else:
35            wordLenghtToTake = int((wordLenght - 2) / 2)35            wordLenghtToTake = int((wordLenght - 2) / 2)
3636
n37        print(word[wordLenght - wordLenghtToTake : wordLenght])n37        return (word[wordLenght - wordLenghtToTake : wordLenght])
3838
39def middle(word):39def middle(word):
40    wordLenght = len(word)40    wordLenght = len(word)
41    valueRemaining = wordLenght % 341    valueRemaining = wordLenght % 3
4242
43    if valueRemaining == 0:43    if valueRemaining == 0:
44        wordLenghtToTake = int(wordLenght / 3)44        wordLenghtToTake = int(wordLenght / 3)
n45        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])n45        return (word[wordLenghtToTake : wordLenght - wordLenghtToTake])
46    elif valueRemaining == 1:46    elif valueRemaining == 1:
47        wordLenghtToTake = int(((wordLenght)-1) / 3)47        wordLenghtToTake = int(((wordLenght)-1) / 3)
n48        print(word[wordLenghtToTake  : wordLenght - wordLenghtToTake])n48        return (word[wordLenghtToTake  : wordLenght - wordLenghtToTake])
49    else:49    else:
50        wordLenghtToTake = 050        wordLenghtToTake = 0
51        if (wordLenght - 1) % 2 == 0:51        if (wordLenght - 1) % 2 == 0:
52            wordLenghtToTake = int((wordLenght - 1) / 2)52            wordLenghtToTake = int((wordLenght - 1) / 2)
53        else:53        else:
54            wordLenghtToTake = int((wordLenght - 2) / 2)54            wordLenghtToTake = int((wordLenght - 2) / 2)
5555
n56        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])n56        return (word[wordLenghtToTake : wordLenght - wordLenghtToTake])
5757
58def split_sentence(sentece):58def split_sentence(sentece):
t59    result = sentece.split(' ')t59    splitedSentence = sentece.split(' ')
60    for word in result:60    result = []
61        beginning(word)61    for word in splitedSentence:
62        middle(word)62        beginningOfWord = beginning(word)
63        end(word)63        middleOfWord = middle(word)
64        endOfWord = end(word)
65        result.append((beginningOfWord,middleOfWord,endOfWord))
66    
67    print(result)
6468
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1def beginning(word):f1def beginning(word):
2    wordLenght = len(word)2    wordLenght = len(word)
3    valueRemaining = wordLenght % 33    valueRemaining = wordLenght % 3
44
5    if valueRemaining == 0:5    if valueRemaining == 0:
6        wordLenghtToTake = int(wordLenght / 3)6        wordLenghtToTake = int(wordLenght / 3)
7        print(word[0:wordLenghtToTake])7        print(word[0:wordLenghtToTake])
8    elif valueRemaining == 1:8    elif valueRemaining == 1:
9        wordLenghtToTake = int(((wordLenght)-1) / 3)9        wordLenghtToTake = int(((wordLenght)-1) / 3)
10        print(word[0:wordLenghtToTake])10        print(word[0:wordLenghtToTake])
11    else:11    else:
12        wordLenghtToTake = 012        wordLenghtToTake = 0
13        if (wordLenght - 1) % 2 == 0:13        if (wordLenght - 1) % 2 == 0:
14            wordLenghtToTake = int((wordLenght - 1) / 2)14            wordLenghtToTake = int((wordLenght - 1) / 2)
15        else:15        else:
16            wordLenghtToTake = int((wordLenght - 2) / 2)16            wordLenghtToTake = int((wordLenght - 2) / 2)
1717
18        print(word[0:wordLenghtToTake])18        print(word[0:wordLenghtToTake])
1919
20def end(word):20def end(word):
21    wordLenght = len(word)21    wordLenght = len(word)
22    valueRemaining = wordLenght % 322    valueRemaining = wordLenght % 3
2323
24    if valueRemaining == 0:24    if valueRemaining == 0:
25        wordLenghtToTake = int(wordLenght / 3)25        wordLenghtToTake = int(wordLenght / 3)
26        print(word[wordLenght - wordLenghtToTake : wordLenght])26        print(word[wordLenght - wordLenghtToTake : wordLenght])
27    elif valueRemaining == 1:27    elif valueRemaining == 1:
28        wordLenghtToTake = int(((wordLenght)-1) / 3)28        wordLenghtToTake = int(((wordLenght)-1) / 3)
29        print(word[wordLenght - wordLenghtToTake : wordLenght])29        print(word[wordLenght - wordLenghtToTake : wordLenght])
30    else:30    else:
31        wordLenghtToTake = 031        wordLenghtToTake = 0
32        if (wordLenght - 1) % 2 == 0:32        if (wordLenght - 1) % 2 == 0:
33            wordLenghtToTake = int((wordLenght - 1) / 2)33            wordLenghtToTake = int((wordLenght - 1) / 2)
34        else:34        else:
35            wordLenghtToTake = int((wordLenght - 2) / 2)35            wordLenghtToTake = int((wordLenght - 2) / 2)
3636
37        print(word[wordLenght - wordLenghtToTake : wordLenght])37        print(word[wordLenght - wordLenghtToTake : wordLenght])
3838
39def middle(word):39def middle(word):
40    wordLenght = len(word)40    wordLenght = len(word)
41    valueRemaining = wordLenght % 341    valueRemaining = wordLenght % 3
4242
43    if valueRemaining == 0:43    if valueRemaining == 0:
44        wordLenghtToTake = int(wordLenght / 3)44        wordLenghtToTake = int(wordLenght / 3)
45        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])45        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])
46    elif valueRemaining == 1:46    elif valueRemaining == 1:
47        wordLenghtToTake = int(((wordLenght)-1) / 3)47        wordLenghtToTake = int(((wordLenght)-1) / 3)
48        print(word[wordLenghtToTake  : wordLenght - wordLenghtToTake])48        print(word[wordLenghtToTake  : wordLenght - wordLenghtToTake])
49    else:49    else:
50        wordLenghtToTake = 050        wordLenghtToTake = 0
51        if (wordLenght - 1) % 2 == 0:51        if (wordLenght - 1) % 2 == 0:
52            wordLenghtToTake = int((wordLenght - 1) / 2)52            wordLenghtToTake = int((wordLenght - 1) / 2)
53        else:53        else:
54            wordLenghtToTake = int((wordLenght - 2) / 2)54            wordLenghtToTake = int((wordLenght - 2) / 2)
5555
56        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])56        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])
5757
t58def split_sentence(split_sentence):t58def split_sentence(sentece):
59    print()59    result = sentece.split(' ')
60    for word in result:
61        beginning(word)
62        middle(word)
63        end(word)
64 
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1def beginning(word):f1def beginning(word):
2    wordLenght = len(word)2    wordLenght = len(word)
3    valueRemaining = wordLenght % 33    valueRemaining = wordLenght % 3
44
5    if valueRemaining == 0:5    if valueRemaining == 0:
6        wordLenghtToTake = int(wordLenght / 3)6        wordLenghtToTake = int(wordLenght / 3)
7        print(word[0:wordLenghtToTake])7        print(word[0:wordLenghtToTake])
8    elif valueRemaining == 1:8    elif valueRemaining == 1:
9        wordLenghtToTake = int(((wordLenght)-1) / 3)9        wordLenghtToTake = int(((wordLenght)-1) / 3)
10        print(word[0:wordLenghtToTake])10        print(word[0:wordLenghtToTake])
11    else:11    else:
12        wordLenghtToTake = 012        wordLenghtToTake = 0
13        if (wordLenght - 1) % 2 == 0:13        if (wordLenght - 1) % 2 == 0:
14            wordLenghtToTake = int((wordLenght - 1) / 2)14            wordLenghtToTake = int((wordLenght - 1) / 2)
15        else:15        else:
16            wordLenghtToTake = int((wordLenght - 2) / 2)16            wordLenghtToTake = int((wordLenght - 2) / 2)
1717
18        print(word[0:wordLenghtToTake])18        print(word[0:wordLenghtToTake])
1919
20def end(word):20def end(word):
21    wordLenght = len(word)21    wordLenght = len(word)
22    valueRemaining = wordLenght % 322    valueRemaining = wordLenght % 3
2323
24    if valueRemaining == 0:24    if valueRemaining == 0:
25        wordLenghtToTake = int(wordLenght / 3)25        wordLenghtToTake = int(wordLenght / 3)
26        print(word[wordLenght - wordLenghtToTake : wordLenght])26        print(word[wordLenght - wordLenghtToTake : wordLenght])
27    elif valueRemaining == 1:27    elif valueRemaining == 1:
28        wordLenghtToTake = int(((wordLenght)-1) / 3)28        wordLenghtToTake = int(((wordLenght)-1) / 3)
29        print(word[wordLenght - wordLenghtToTake : wordLenght])29        print(word[wordLenght - wordLenghtToTake : wordLenght])
30    else:30    else:
31        wordLenghtToTake = 031        wordLenghtToTake = 0
32        if (wordLenght - 1) % 2 == 0:32        if (wordLenght - 1) % 2 == 0:
33            wordLenghtToTake = int((wordLenght - 1) / 2)33            wordLenghtToTake = int((wordLenght - 1) / 2)
34        else:34        else:
35            wordLenghtToTake = int((wordLenght - 2) / 2)35            wordLenghtToTake = int((wordLenght - 2) / 2)
3636
37        print(word[wordLenght - wordLenghtToTake : wordLenght])37        print(word[wordLenght - wordLenghtToTake : wordLenght])
3838
39def middle(word):39def middle(word):
40    wordLenght = len(word)40    wordLenght = len(word)
41    valueRemaining = wordLenght % 341    valueRemaining = wordLenght % 3
4242
43    if valueRemaining == 0:43    if valueRemaining == 0:
44        wordLenghtToTake = int(wordLenght / 3)44        wordLenghtToTake = int(wordLenght / 3)
45        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])45        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])
46    elif valueRemaining == 1:46    elif valueRemaining == 1:
47        wordLenghtToTake = int(((wordLenght)-1) / 3)47        wordLenghtToTake = int(((wordLenght)-1) / 3)
48        print(word[wordLenghtToTake  : wordLenght - wordLenghtToTake])48        print(word[wordLenghtToTake  : wordLenght - wordLenghtToTake])
49    else:49    else:
50        wordLenghtToTake = 050        wordLenghtToTake = 0
51        if (wordLenght - 1) % 2 == 0:51        if (wordLenght - 1) % 2 == 0:
52            wordLenghtToTake = int((wordLenght - 1) / 2)52            wordLenghtToTake = int((wordLenght - 1) / 2)
53        else:53        else:
54            wordLenghtToTake = int((wordLenght - 2) / 2)54            wordLenghtToTake = int((wordLenght - 2) / 2)
5555
56        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])56        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])
5757
tt58def split_sentence(split_sentence):
59    print()
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1def beginning(word):f1def beginning(word):
2    wordLenght = len(word)2    wordLenght = len(word)
3    valueRemaining = wordLenght % 33    valueRemaining = wordLenght % 3
44
5    if valueRemaining == 0:5    if valueRemaining == 0:
6        wordLenghtToTake = int(wordLenght / 3)6        wordLenghtToTake = int(wordLenght / 3)
7        print(word[0:wordLenghtToTake])7        print(word[0:wordLenghtToTake])
8    elif valueRemaining == 1:8    elif valueRemaining == 1:
9        wordLenghtToTake = int(((wordLenght)-1) / 3)9        wordLenghtToTake = int(((wordLenght)-1) / 3)
10        print(word[0:wordLenghtToTake])10        print(word[0:wordLenghtToTake])
11    else:11    else:
12        wordLenghtToTake = 012        wordLenghtToTake = 0
13        if (wordLenght - 1) % 2 == 0:13        if (wordLenght - 1) % 2 == 0:
14            wordLenghtToTake = int((wordLenght - 1) / 2)14            wordLenghtToTake = int((wordLenght - 1) / 2)
15        else:15        else:
16            wordLenghtToTake = int((wordLenght - 2) / 2)16            wordLenghtToTake = int((wordLenght - 2) / 2)
1717
18        print(word[0:wordLenghtToTake])18        print(word[0:wordLenghtToTake])
1919
20def end(word):20def end(word):
21    wordLenght = len(word)21    wordLenght = len(word)
22    valueRemaining = wordLenght % 322    valueRemaining = wordLenght % 3
2323
24    if valueRemaining == 0:24    if valueRemaining == 0:
25        wordLenghtToTake = int(wordLenght / 3)25        wordLenghtToTake = int(wordLenght / 3)
26        print(word[wordLenght - wordLenghtToTake : wordLenght])26        print(word[wordLenght - wordLenghtToTake : wordLenght])
27    elif valueRemaining == 1:27    elif valueRemaining == 1:
28        wordLenghtToTake = int(((wordLenght)-1) / 3)28        wordLenghtToTake = int(((wordLenght)-1) / 3)
29        print(word[wordLenght - wordLenghtToTake : wordLenght])29        print(word[wordLenght - wordLenghtToTake : wordLenght])
30    else:30    else:
31        wordLenghtToTake = 031        wordLenghtToTake = 0
32        if (wordLenght - 1) % 2 == 0:32        if (wordLenght - 1) % 2 == 0:
33            wordLenghtToTake = int((wordLenght - 1) / 2)33            wordLenghtToTake = int((wordLenght - 1) / 2)
34        else:34        else:
35            wordLenghtToTake = int((wordLenght - 2) / 2)35            wordLenghtToTake = int((wordLenght - 2) / 2)
3636
37        print(word[wordLenght - wordLenghtToTake : wordLenght])37        print(word[wordLenght - wordLenghtToTake : wordLenght])
3838
39def middle(word):39def middle(word):
40    wordLenght = len(word)40    wordLenght = len(word)
41    valueRemaining = wordLenght % 341    valueRemaining = wordLenght % 3
4242
43    if valueRemaining == 0:43    if valueRemaining == 0:
44        wordLenghtToTake = int(wordLenght / 3)44        wordLenghtToTake = int(wordLenght / 3)
45        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])45        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])
46    elif valueRemaining == 1:46    elif valueRemaining == 1:
47        wordLenghtToTake = int(((wordLenght)-1) / 3)47        wordLenghtToTake = int(((wordLenght)-1) / 3)
48        print(word[wordLenghtToTake  : wordLenght - wordLenghtToTake])48        print(word[wordLenghtToTake  : wordLenght - wordLenghtToTake])
49    else:49    else:
50        wordLenghtToTake = 050        wordLenghtToTake = 0
51        if (wordLenght - 1) % 2 == 0:51        if (wordLenght - 1) % 2 == 0:
52            wordLenghtToTake = int((wordLenght - 1) / 2)52            wordLenghtToTake = int((wordLenght - 1) / 2)
53        else:53        else:
54            wordLenghtToTake = int((wordLenght - 2) / 2)54            wordLenghtToTake = int((wordLenght - 2) / 2)
5555
56        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])56        print(word[wordLenghtToTake : wordLenght - wordLenghtToTake])
5757
t58testSequence = ['шах', 'враца', 'барабани','цици','домашни']t
59 
60for word in testSequence:
61    beginning(word)
62    middle(word)
63    end(word)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op