diff --git a/day15/image.svg b/day15/image.svg new file mode 100644 index 0000000..0260536 --- /dev/null +++ b/day15/image.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/day15/svg.py b/day15/svg.py new file mode 100644 index 0000000..1883c82 --- /dev/null +++ b/day15/svg.py @@ -0,0 +1,26 @@ +data = [] +for line in open("input"): + words = line.replace(":", "").replace(",","").split() + coords = [int(w[w.index('=')+1:]) for w in words if '=' in w] + data.append(coords) + +import colorsys +def hsl(h,s,l): + r,g,b = colorsys.hls_to_rgb(h/360,l,s) + return int(r*255),int(g*255),int(b*255) + +colors = [] +for i in range(len(data)): + hue = i*300/len(data) + colors.append("#%02x%02x%02x" % hsl(hue, 1, .5)) + +print('') +for i,(sx,sy,bx,by) in enumerate(data): + dx = abs(sx-bx) + dy = abs(sy-by) + d = dx+dy + path = [(sx+d,sy),(sx,sy+d),(sx-d,sy),(sx,sy-d)] + s = "M %d %d" % (path[-1]) + " ".join("L %d %d" % (x,y) for x,y in path) + print('' % (s,colors[i])) +#print('') +print('')