1def get_split_index(word):
 2    w_len = len(word)
 3
 4    if w_len%3 == 2:
 5        return (w_len + 1) // 3
 6
 7    return w_len // 3
 8
 9def beginning(word):
10    return word[:get_split_index(word)]
11
12def middle(word):
13    split_index = get_split_index(word)
14    return word if len(word) == 1 else word[split_index:-split_index]
15
16def end(word):
17    return '' if len(word) == 1 else word[-get_split_index(word):]
18
19def split_word(word):
20    return beginning(word), middle(word), end(word)
21
22def split_sentence(sentence):
23    return [split_word(word) for word in sentence.split()]
............
----------------------------------------------------------------------
Ran 12 tests in 0.000s
OK
| f | 1 | def get_split_index(word): | f | 1 | def get_split_index(word): | 
| 2 | w_len = len(word) | 2 | w_len = len(word) | ||
| 3 | 3 | ||||
| n | 4 | if(w_len%3 == 2): | n | 4 | if w_len%3 == 2: | 
| 5 | return (w_len+1)//3 | 5 | return (w_len + 1) // 3 | ||
| 6 | 6 | ||||
| t | 7 | return w_len//3 | t | 7 | return w_len // 3 | 
| 8 | 8 | ||||
| 9 | def beginning(word): | 9 | def beginning(word): | ||
| 10 | return word[:get_split_index(word)] | 10 | return word[:get_split_index(word)] | ||
| 11 | 11 | ||||
| 12 | def middle(word): | 12 | def middle(word): | ||
| 13 | split_index = get_split_index(word) | 13 | split_index = get_split_index(word) | ||
| 14 | return word if len(word) == 1 else word[split_index:-split_index] | 14 | return word if len(word) == 1 else word[split_index:-split_index] | ||
| 15 | 15 | ||||
| 16 | def end(word): | 16 | def end(word): | ||
| 17 | return '' if len(word) == 1 else word[-get_split_index(word):] | 17 | return '' if len(word) == 1 else word[-get_split_index(word):] | ||
| 18 | 18 | ||||
| 19 | def split_word(word): | 19 | def split_word(word): | ||
| 20 | return beginning(word), middle(word), end(word) | 20 | return beginning(word), middle(word), end(word) | ||
| 21 | 21 | ||||
| 22 | def split_sentence(sentence): | 22 | def split_sentence(sentence): | ||
| 23 | return [split_word(word) for word in sentence.split()] | 23 | return [split_word(word) for word in sentence.split()] | 
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 
 | 
 | |||||||||
| f | 1 | def get_split_index(word): | f | 1 | def get_split_index(word): | 
| 2 | w_len = len(word) | 2 | w_len = len(word) | ||
| n | 3 | return int((w_len+0.5*(w_len%3))//3) # it's not practical, but it is cool :) | n | 3 | |
| 4 | if(w_len%3 == 2): | ||||
| 5 | return (w_len+1)//3 | ||||
| 6 | |||||
| 7 | return w_len//3 | ||||
| 4 | 8 | ||||
| 5 | def beginning(word): | 9 | def beginning(word): | ||
| 6 | return word[:get_split_index(word)] | 10 | return word[:get_split_index(word)] | ||
| 7 | 11 | ||||
| 8 | def middle(word): | 12 | def middle(word): | ||
| 9 | split_index = get_split_index(word) | 13 | split_index = get_split_index(word) | ||
| n | 10 | return word if len(word)==1 else word[split_index:-split_index] | n | 14 | return word if len(word) == 1 else word[split_index:-split_index] | 
| 11 | 15 | ||||
| 12 | def end(word): | 16 | def end(word): | ||
| n | 13 | return '' if len(word)==1 else word[-get_split_index(word):] | n | 17 | return '' if len(word) == 1 else word[-get_split_index(word):] | 
| 14 | 18 | ||||
| 15 | def split_word(word): | 19 | def split_word(word): | ||
| 16 | return beginning(word), middle(word), end(word) | 20 | return beginning(word), middle(word), end(word) | ||
| 17 | 21 | ||||
| 18 | def split_sentence(sentence): | 22 | def split_sentence(sentence): | ||
| t | 19 | return [split_word(word) for word in sentence.split(' ')] | t | 23 | return [split_word(word) for word in sentence.split()] | 
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 
 | 
 | |||||||||