-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (26 loc) · 814 Bytes
/
main.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
from collections import Counter as counter
def solution(A):
final_list = []
adition_list = []
for data in A:
str_num = str(data)
addition_val = 0
for i in range(len(str_num)):
addition_val += int(str_num[i])
adition_list.append(addition_val)
count_dict = counter(adition_list)
for key in count_dict:
not_avail_flag = False
if count_dict[key] > 1:
index = [i for i, e in enumerate(adition_list) if e == key]
ret_list = []
for val in index:
ret_list.append(A[val])
final_list.append(tuple(ret_list))
else:
not_avail_flag = True
if not_avail_flag:
return -1
else:
return tuple(final_list)
print(method([51, 17, 42, 62]))