aoc2022/d15/draw.py

41 lines
897 B
Python
Raw Permalink Normal View History

import sys
from collections import defaultdict
S = set()
B = set()
P = dict()
Q = defaultdict(list)
for l in sys.stdin.read().splitlines():
(_,_,X,Y,_,_,_,_,A,J) = l.split(" ")
x = int(X[2:-1])
y = int(Y[2:-1])
a = int(A[2:-1])
b = int(J[2:])
S.add((x,y))
B.add((a,b))
P[(x,y)] = (a,b)
Q[(a,b)].append((x,y))
if False:
print("digraph G {")
print("overlap = false;")
def toid(x):
(x,y) = x
return str(x).replace("-","m")+"_"+str(y).replace("-","m")
for (k,v) in P.items():
print("S_"+toid(k), "->", "B_"+toid(v),";")
print('}')
if True:
print("digraph G {")
print("overlap = false;")
def toid(x):
(x,y) = x
return str(x).replace("-","m")+"_"+str(y).replace("-","m")
for (k,V) in Q.items():
for v in V:
print("B_"+toid(k), "->", "C_"+toid(v),";")
print('}')