-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcirclecross.py
More file actions
34 lines (28 loc) · 798 Bytes
/
circlecross.py
File metadata and controls
34 lines (28 loc) · 798 Bytes
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
# import time
# start_time = time.time()
with open("circlecross.in","r") as f_in:
ALPHA_TWICE = f_in.readline().strip("\n")
i = ctr = 0
new_alpha = ""
while True:
if ALPHA_TWICE[i] == ALPHA_TWICE[i+1]:
ctr += 2
i += 2
else:
new_alpha += ALPHA_TWICE[i]
i += 1
if i > 50:
break
pairs = []
for i, v in enumerate(new_alpha):
for j in range(i+1,len(new_alpha)):
if v == new_alpha[j]:
continue
pair = [v,new_alpha[j]]
if pair not in pairs:
pairs.append(pair)
else:
pairs.remove(pair)
with open("circlecross.out","w") as f_out:
f_out.write(str(len(pairs)//2) + "\n")
# print("time elapsed: {:.2f}s".format(time.time() - start_time))