1def beginning(word):
2 if len(word) % 3 == 0 or len(word) % 3 == 1:
3 length = int(len(word) / 3)
4 result = word[:length]
5 elif len(word) % 3 == 2:
6 length = int((len(word) / 3) + 1)
7 result = word[:length]
8
9 return result
10
11def middle(word):
12 if len(word) % 3 == 0:
13 length = int(len(word) / 3)
14 result = word[length:length*2]
15 elif len(word) % 3 == 2:
16 length = int((len(word) / 3) + 1)
17 result = word[length:length*2 - 1]
18 elif len(word) % 3 == 1:
19 length = int((len(word) / 3))
20 result = word[length:length*2 + 1]
21
22 return result
23
24def end(word):
25 if len(word) % 3 == 0:
26 length = int(len(word) / 3)
27 result = word[length*2:]
28 elif len(word) % 3 == 2:
29 length = int((len(word) / 3) + 1)
30 result = word[length*2 - 1:]
31 elif len(word) % 3 == 1:
32 length = int((len(word) / 3))
33 result = word[length*2 + 1:]
34
35 return result
36
37
38def split_sentence(sentence):
39 separated = sentence.split()
40 result = []
41 for i in separated:
42 triple = (beginning(i), middle(i), end(i))
43 result.append(triple)
44 return result
45
46
47sentence = "Who are you"
48splited = split_sentence(sentence)
49print(splited)
[('W', 'h', 'o'), ('a', 'r', 'e'), ('y', 'o', 'u')]
............
----------------------------------------------------------------------
Ran 12 tests in 0.000s
OK
f | 1 | def beginning(word): | f | 1 | def beginning(word): |
2 | if len(word) % 3 == 0 or len(word) % 3 == 1: | 2 | if len(word) % 3 == 0 or len(word) % 3 == 1: | ||
3 | length = int(len(word) / 3) | 3 | length = int(len(word) / 3) | ||
4 | result = word[:length] | 4 | result = word[:length] | ||
5 | elif len(word) % 3 == 2: | 5 | elif len(word) % 3 == 2: | ||
6 | length = int((len(word) / 3) + 1) | 6 | length = int((len(word) / 3) + 1) | ||
7 | result = word[:length] | 7 | result = word[:length] | ||
8 | 8 | ||||
9 | return result | 9 | return result | ||
10 | 10 | ||||
11 | def middle(word): | 11 | def middle(word): | ||
12 | if len(word) % 3 == 0: | 12 | if len(word) % 3 == 0: | ||
13 | length = int(len(word) / 3) | 13 | length = int(len(word) / 3) | ||
14 | result = word[length:length*2] | 14 | result = word[length:length*2] | ||
15 | elif len(word) % 3 == 2: | 15 | elif len(word) % 3 == 2: | ||
16 | length = int((len(word) / 3) + 1) | 16 | length = int((len(word) / 3) + 1) | ||
17 | result = word[length:length*2 - 1] | 17 | result = word[length:length*2 - 1] | ||
18 | elif len(word) % 3 == 1: | 18 | elif len(word) % 3 == 1: | ||
19 | length = int((len(word) / 3)) | 19 | length = int((len(word) / 3)) | ||
20 | result = word[length:length*2 + 1] | 20 | result = word[length:length*2 + 1] | ||
21 | 21 | ||||
22 | return result | 22 | return result | ||
23 | 23 | ||||
24 | def end(word): | 24 | def end(word): | ||
25 | if len(word) % 3 == 0: | 25 | if len(word) % 3 == 0: | ||
26 | length = int(len(word) / 3) | 26 | length = int(len(word) / 3) | ||
27 | result = word[length*2:] | 27 | result = word[length*2:] | ||
28 | elif len(word) % 3 == 2: | 28 | elif len(word) % 3 == 2: | ||
29 | length = int((len(word) / 3) + 1) | 29 | length = int((len(word) / 3) + 1) | ||
30 | result = word[length*2 - 1:] | 30 | result = word[length*2 - 1:] | ||
31 | elif len(word) % 3 == 1: | 31 | elif len(word) % 3 == 1: | ||
32 | length = int((len(word) / 3)) | 32 | length = int((len(word) / 3)) | ||
33 | result = word[length*2 + 1:] | 33 | result = word[length*2 + 1:] | ||
34 | 34 | ||||
35 | return result | 35 | return result | ||
36 | 36 | ||||
37 | 37 | ||||
38 | def split_sentence(sentence): | 38 | def split_sentence(sentence): | ||
39 | separated = sentence.split() | 39 | separated = sentence.split() | ||
40 | result = [] | 40 | result = [] | ||
41 | for i in separated: | 41 | for i in separated: | ||
42 | triple = (beginning(i), middle(i), end(i)) | 42 | triple = (beginning(i), middle(i), end(i)) | ||
43 | result.append(triple) | 43 | result.append(triple) | ||
44 | return result | 44 | return result | ||
45 | 45 | ||||
46 | 46 | ||||
t | 47 | t | 47 | sentence = "Who are you" | |
48 | splited = split_sentence(sentence) | 48 | splited = split_sentence(sentence) | ||
49 | print(splited) | 49 | print(splited) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def beginning(word): | f | 1 | def beginning(word): |
n | 2 | if len(word) % 3 == 0: | n | 2 | if len(word) % 3 == 0 or len(word) % 3 == 1: |
3 | length = int(len(word) / 3) | 3 | length = int(len(word) / 3) | ||
4 | result = word[:length] | 4 | result = word[:length] | ||
5 | elif len(word) % 3 == 2: | 5 | elif len(word) % 3 == 2: | ||
6 | length = int((len(word) / 3) + 1) | 6 | length = int((len(word) / 3) + 1) | ||
n | 7 | result = word[:length] | n | ||
8 | elif len(word) % 3 == 1: | ||||
9 | length = int((len(word) / 3)) | ||||
10 | result = word[:length] | 7 | result = word[:length] | ||
11 | 8 | ||||
12 | return result | 9 | return result | ||
13 | 10 | ||||
14 | def middle(word): | 11 | def middle(word): | ||
15 | if len(word) % 3 == 0: | 12 | if len(word) % 3 == 0: | ||
16 | length = int(len(word) / 3) | 13 | length = int(len(word) / 3) | ||
17 | result = word[length:length*2] | 14 | result = word[length:length*2] | ||
18 | elif len(word) % 3 == 2: | 15 | elif len(word) % 3 == 2: | ||
19 | length = int((len(word) / 3) + 1) | 16 | length = int((len(word) / 3) + 1) | ||
n | 20 | result = word[length:length*2-1] | n | 17 | result = word[length:length*2 - 1] |
21 | elif len(word) % 3 == 1: | 18 | elif len(word) % 3 == 1: | ||
22 | length = int((len(word) / 3)) | 19 | length = int((len(word) / 3)) | ||
n | 23 | result = word[length:length*2+1] | n | 20 | result = word[length:length*2 + 1] |
24 | 21 | ||||
25 | return result | 22 | return result | ||
26 | 23 | ||||
27 | def end(word): | 24 | def end(word): | ||
28 | if len(word) % 3 == 0: | 25 | if len(word) % 3 == 0: | ||
29 | length = int(len(word) / 3) | 26 | length = int(len(word) / 3) | ||
30 | result = word[length*2:] | 27 | result = word[length*2:] | ||
31 | elif len(word) % 3 == 2: | 28 | elif len(word) % 3 == 2: | ||
32 | length = int((len(word) / 3) + 1) | 29 | length = int((len(word) / 3) + 1) | ||
n | 33 | result = word[length*2-1:] | n | 30 | result = word[length*2 - 1:] |
34 | elif len(word) % 3 == 1: | 31 | elif len(word) % 3 == 1: | ||
35 | length = int((len(word) / 3)) | 32 | length = int((len(word) / 3)) | ||
n | 36 | result = word[length*2+1:] | n | 33 | result = word[length*2 + 1:] |
37 | 34 | ||||
38 | return result | 35 | return result | ||
39 | 36 | ||||
40 | 37 | ||||
41 | def split_sentence(sentence): | 38 | def split_sentence(sentence): | ||
42 | separated = sentence.split() | 39 | separated = sentence.split() | ||
n | 43 | result=[] | n | 40 | result = [] |
44 | for i in separated: | 41 | for i in separated: | ||
45 | triple = (beginning(i), middle(i), end(i)) | 42 | triple = (beginning(i), middle(i), end(i)) | ||
46 | result.append(triple) | 43 | result.append(triple) | ||
47 | return result | 44 | return result | ||
48 | 45 | ||||
49 | 46 | ||||
50 | 47 | ||||
t | 51 | t | |||
52 | sentence = input() | ||||
53 | splited = split_sentence(sentence) | 48 | splited = split_sentence(sentence) | ||
54 | print(splited) | 49 | print(splited) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
t | 1 | def beginning(word): | t | 1 | def beginning(word): |
2 | if len(word) % 3 == 0: | 2 | if len(word) % 3 == 0: | ||
3 | length = int(len(word) / 3) | 3 | length = int(len(word) / 3) | ||
4 | result = word[:length] | 4 | result = word[:length] | ||
5 | elif len(word) % 3 == 2: | 5 | elif len(word) % 3 == 2: | ||
6 | length = int((len(word) / 3) + 1) | 6 | length = int((len(word) / 3) + 1) | ||
7 | result = word[:length] | 7 | result = word[:length] | ||
8 | elif len(word) % 3 == 1: | 8 | elif len(word) % 3 == 1: | ||
9 | length = int((len(word) / 3)) | 9 | length = int((len(word) / 3)) | ||
10 | result = word[:length] | 10 | result = word[:length] | ||
11 | 11 | ||||
12 | return result | 12 | return result | ||
13 | 13 | ||||
14 | def middle(word): | 14 | def middle(word): | ||
15 | if len(word) % 3 == 0: | 15 | if len(word) % 3 == 0: | ||
16 | length = int(len(word) / 3) | 16 | length = int(len(word) / 3) | ||
17 | result = word[length:length*2] | 17 | result = word[length:length*2] | ||
18 | elif len(word) % 3 == 2: | 18 | elif len(word) % 3 == 2: | ||
19 | length = int((len(word) / 3) + 1) | 19 | length = int((len(word) / 3) + 1) | ||
20 | result = word[length:length*2-1] | 20 | result = word[length:length*2-1] | ||
21 | elif len(word) % 3 == 1: | 21 | elif len(word) % 3 == 1: | ||
22 | length = int((len(word) / 3)) | 22 | length = int((len(word) / 3)) | ||
23 | result = word[length:length*2+1] | 23 | result = word[length:length*2+1] | ||
24 | 24 | ||||
25 | return result | 25 | return result | ||
26 | 26 | ||||
27 | def end(word): | 27 | def end(word): | ||
28 | if len(word) % 3 == 0: | 28 | if len(word) % 3 == 0: | ||
29 | length = int(len(word) / 3) | 29 | length = int(len(word) / 3) | ||
30 | result = word[length*2:] | 30 | result = word[length*2:] | ||
31 | elif len(word) % 3 == 2: | 31 | elif len(word) % 3 == 2: | ||
32 | length = int((len(word) / 3) + 1) | 32 | length = int((len(word) / 3) + 1) | ||
33 | result = word[length*2-1:] | 33 | result = word[length*2-1:] | ||
34 | elif len(word) % 3 == 1: | 34 | elif len(word) % 3 == 1: | ||
35 | length = int((len(word) / 3)) | 35 | length = int((len(word) / 3)) | ||
36 | result = word[length*2+1:] | 36 | result = word[length*2+1:] | ||
37 | 37 | ||||
38 | return result | 38 | return result | ||
39 | 39 | ||||
40 | 40 | ||||
41 | def split_sentence(sentence): | 41 | def split_sentence(sentence): | ||
42 | separated = sentence.split() | 42 | separated = sentence.split() | ||
43 | result=[] | 43 | result=[] | ||
44 | for i in separated: | 44 | for i in separated: | ||
45 | triple = (beginning(i), middle(i), end(i)) | 45 | triple = (beginning(i), middle(i), end(i)) | ||
46 | result.append(triple) | 46 | result.append(triple) | ||
47 | return result | 47 | return result | ||
48 | 48 | ||||
49 | 49 | ||||
50 | 50 | ||||
51 | 51 | ||||
52 | sentence = input() | 52 | sentence = input() | ||
53 | splited = split_sentence(sentence) | 53 | splited = split_sentence(sentence) | ||
54 | print(splited) | 54 | print(splited) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def beginning(word): | f | 1 | def beginning(word): |
2 | if len(word) % 3 == 0: | 2 | if len(word) % 3 == 0: | ||
3 | length = int(len(word) / 3) | 3 | length = int(len(word) / 3) | ||
4 | result = word[:length] | 4 | result = word[:length] | ||
5 | elif len(word) % 3 == 2: | 5 | elif len(word) % 3 == 2: | ||
6 | length = int((len(word) / 3) + 1) | 6 | length = int((len(word) / 3) + 1) | ||
7 | result = word[:length] | 7 | result = word[:length] | ||
8 | elif len(word) % 3 == 1: | 8 | elif len(word) % 3 == 1: | ||
9 | length = int((len(word) / 3)) | 9 | length = int((len(word) / 3)) | ||
10 | result = word[:length] | 10 | result = word[:length] | ||
11 | 11 | ||||
12 | return result | 12 | return result | ||
13 | 13 | ||||
14 | def middle(word): | 14 | def middle(word): | ||
15 | if len(word) % 3 == 0: | 15 | if len(word) % 3 == 0: | ||
16 | length = int(len(word) / 3) | 16 | length = int(len(word) / 3) | ||
17 | result = word[length:length*2] | 17 | result = word[length:length*2] | ||
18 | elif len(word) % 3 == 2: | 18 | elif len(word) % 3 == 2: | ||
19 | length = int((len(word) / 3) + 1) | 19 | length = int((len(word) / 3) + 1) | ||
20 | result = word[length:length*2-1] | 20 | result = word[length:length*2-1] | ||
21 | elif len(word) % 3 == 1: | 21 | elif len(word) % 3 == 1: | ||
22 | length = int((len(word) / 3)) | 22 | length = int((len(word) / 3)) | ||
23 | result = word[length:length*2+1] | 23 | result = word[length:length*2+1] | ||
24 | 24 | ||||
25 | return result | 25 | return result | ||
26 | 26 | ||||
27 | def end(word): | 27 | def end(word): | ||
28 | if len(word) % 3 == 0: | 28 | if len(word) % 3 == 0: | ||
29 | length = int(len(word) / 3) | 29 | length = int(len(word) / 3) | ||
30 | result = word[length*2:] | 30 | result = word[length*2:] | ||
31 | elif len(word) % 3 == 2: | 31 | elif len(word) % 3 == 2: | ||
32 | length = int((len(word) / 3) + 1) | 32 | length = int((len(word) / 3) + 1) | ||
33 | result = word[length*2-1:] | 33 | result = word[length*2-1:] | ||
34 | elif len(word) % 3 == 1: | 34 | elif len(word) % 3 == 1: | ||
35 | length = int((len(word) / 3)) | 35 | length = int((len(word) / 3)) | ||
36 | result = word[length*2+1:] | 36 | result = word[length*2+1:] | ||
37 | 37 | ||||
38 | return result | 38 | return result | ||
39 | 39 | ||||
40 | 40 | ||||
41 | def split_sentence(sentence): | 41 | def split_sentence(sentence): | ||
42 | separated = sentence.split() | 42 | separated = sentence.split() | ||
43 | result=[] | 43 | result=[] | ||
44 | for i in separated: | 44 | for i in separated: | ||
45 | triple = (beginning(i), middle(i), end(i)) | 45 | triple = (beginning(i), middle(i), end(i)) | ||
46 | result.append(triple) | 46 | result.append(triple) | ||
n | 47 | print(result) | n | 47 | return result |
48 | 48 | ||||
49 | 49 | ||||
50 | 50 | ||||
51 | 51 | ||||
52 | sentence = input() | 52 | sentence = input() | ||
t | 53 | split_sentence(sentence) | t | 53 | splited = split_sentence(sentence) |
54 | print(splited) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|