blob: 401ad7d90c9a275f2ae99645ce266999a029d399 (
plain)
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
|
from collections import defaultdict
import random
input = "data/23_2024.txt"
data = open(input).read().strip()
dic = defaultdict(set)
for line in data.split("\n"):
(
a,
b,
) = line.split("-")
dic[a].add(b)
dic[b].add(a)
xs, p1 = sorted(dic.keys()), 0
for i, a in enumerate(xs):
for j in range(i + 1, len(xs)):
for k in range(j + 1, len(xs)):
b = xs[j]
c = xs[k]
if a in dic[b] and a in dic[c] and b in dic[c]:
if a.startswith("t") or b.startswith("t") or c.startswith("t"):
p1 += 1
print(p1)
best = None
for t in range(1000):
random.shuffle(xs)
clique = []
for x in xs:
ok = True
for y in clique:
if x not in dic[y]:
ok = False
if ok:
clique.append(x)
if best is None or len(clique) > len(best):
best = clique
print(",".join(sorted(best)))
|