-
Notifications
You must be signed in to change notification settings - Fork 0
/
dupTask.py
65 lines (41 loc) · 1.59 KB
/
dupTask.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
import json
tasks = [('4R7hQgwD1Rb6fecg4wZ0', 'Task', 26, 8, 2024, 8262024, 'None', 'None', '0000000000', 'None', 'None', 5, 'None'), ('593aw19KkX5DRiL6GXA2', 'lol', 26, 8, 2024, 8262024, 'None', 'Computer Science 1', 'cOspDDRuA7', 'None', 'None', 5, 'None')]
def findDupTask(tasks):
dupTask = []
for i in range(len(tasks)):
counter = 0
for c in range(len(tasks)):
if tasks[i][1] == tasks[c][1]:
counter += 1
if counter > 1:
dupTask.append((tasks[i][0], tasks[i][1], i))
duplicate = {
"groupNum": 1,
"group1": []
}
if len(dupTask) == 0:
return False
else:
duplicate["group1"].append(dupTask[0])
groupNum = 1
foundGroup = False
for i in range(1, len(dupTask)):
anotherGroup = False
beforeGroupNum = duplicate["groupNum"]
for j in range(duplicate["groupNum"]):
if dupTask[i][1] in duplicate[f"group{j+1}"][0][1]:
duplicate[f"group{j+1}"].append(dupTask[i])
anotherGroup = False
foundGroup = True
else:
anotherGroup = True
foundGroup = False
if foundGroup == True:
break
if anotherGroup == True:
groupNum += 1
duplicate["groupNum"] = groupNum
duplicate[f"group{groupNum}"] = [dupTask[i]]
return duplicate
if __name__ == "__main__":
print(json.dumps(findDupTask(tasks), indent=4))