Skip to content

Commit 265e72c

Browse files
authored
Merge pull request #7 from cutenti/1_reverse_lexicographic_order
Added func Reverse lexicographic comparison
2 parents d2c5e7f + 5e1aa33 commit 265e72c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def reverse_compare(str_1, str_2):
2+
len_1 = len(str_1)
3+
len_2 = len(str_2)
4+
5+
for i in range(min(len_1, len_2)):
6+
if str_1[i] > str_2[i]:
7+
return 2 # str_2 > str_1
8+
if str_2[i] > str_1[i]:
9+
return 1 # str_1 > str_2
10+
11+
if len_1 > len_2:
12+
return 1
13+
14+
if len_2 > len_1:
15+
return 2
16+
17+
return 0 # str_1 == str_2

0 commit comments

Comments
 (0)