GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — AdventOfCode/languages/py/2024/23_LANParty.py at main · wolflu05/AdventOfCode Expand file tree/ Copy path23_LANParty.pyMore file actions 47 lines (33 loc) · 843 Bytes / Copy path23_LANParty.pyFile metadata and controls47 lines (33 loc) · 843 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 35 36 37 38 39 40 41 42 43 44 45 46 47 import collections, itertools from lib import * inp = get_input() G = collections.defaultdict(set) for l in inp: a,b = l.split("-") G[a].add(b) G[b].add(a) def all_connected(nodes): for a,b in itertools.combinations(nodes, r=2): if a not in G[b]: return False return True L = len(max(G.values(), key=len)) p1 = None p2 = None for i in range(L, 1, -1): F = set() if p2 is not None and i != 2: continue for k,v in G.items(): for group in itertools.combinations(v, r=i): if all_connected(group): F.add(frozenset((k,*group))) if i == 2: p1 = 0 for group in F: if any(x.startswith("t") for x in group): p1 += 1 if len(F) == 1: p2 = ",".join(sorted(F.pop())) print(p1) print(p2) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |