-
Notifications
You must be signed in to change notification settings - Fork 4
/
flames.py
60 lines (41 loc) · 1.45 KB
/
flames.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def remove_match_char(list1: list, list2: list) -> list:
for i in range(len(list1)):
for j in range(len(list2)):
if list1[i] == list2[j]:
c = list1[i]
list1.remove(c)
list2.remove(c)
list3 = list1 + ["*"] + list2
return [list3, True]
list3 = list1 + ["*"] + list2
return [list3, False]
def flames(p1: str, p2: str) -> str:
p1 = p1.lower()
p1.replace(" ", "")
p1_list = list(p1)
p2 = p2.lower()
p2.replace(" ", "")
p2_list = list(p2)
proceed = True
while proceed:
ret_list = remove_match_char(p1_list, p2_list)
con_list = ret_list[0]
proceed = ret_list[1]
star_index = con_list.index("*")
p1_list = con_list[:star_index]
p2_list = con_list[star_index + 1 :]
count = len(p1_list) + len(p2_list)
result = ["Friends", "Love", "Affection", "Marriage", "Enemy", "Siblings"]
while len(result) > 1:
split_index = count % len(result) - 1
if split_index >= 0:
right = result[split_index + 1 :]
left = result[:split_index]
result = right + left
else:
result = result[: len(result) - 1]
return "Flames between {} and {} is {}".format(p1, p2, result[0])
if __name__ == "__main__":
a = input("Enter the name of player-1: ")
b = input("Enter the name of player-2: ")
print(flames(a, b))