From efc1f117580d4ff3ab272c5d0c566dd66d65bc57 Mon Sep 17 00:00:00 2001 From: setop Date: Wed, 14 Dec 2022 14:34:10 +0100 Subject: [PATCH] day 12, add nice color pictures --- d12/draw.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ d12/input | 41 +++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 d12/draw.py create mode 100644 d12/input diff --git a/d12/draw.py b/d12/draw.py new file mode 100644 index 0000000..9c4b187 --- /dev/null +++ b/d12/draw.py @@ -0,0 +1,58 @@ +import sys +import networkx as netx + +M = [ list(l) for l in sys.stdin.read().splitlines() ] +H = len(M) +W = len(M[0]) +START = tuple() +END = tuple() +G = netx.DiGraph() + +for x in range(H): + for y in range(W): + k = (x,y) + v = M[x][y] + if v == 'S': + START = k + v = 'a' + if v == 'E': + END = k + v = 'z' + v = ord(v) + for dx,dy in [(-1,0),(1,0),(0,-1),(0,1)]: + nx, ny = (x+dx, y+dy) + if nx>=0 and nx=0 and ny