From 2b21efbe67372d675540da5f59f8fc114e44b46c Mon Sep 17 00:00:00 2001 From: Sebastian Seedorf Date: Wed, 16 Dec 2020 17:33:29 +0100 Subject: [PATCH] Day 15 (visualize) --- day15/visualize.py | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/day15/visualize.py b/day15/visualize.py index 2d847a0..ca065be 100644 --- a/day15/visualize.py +++ b/day15/visualize.py @@ -2,21 +2,32 @@ from day15.common import yield_numbers from matplotlib import pyplot as plt import numpy as np -data = list(map(lambda x: (x[1],len(x[2]),len(x[2])/x[0]), yield_numbers("0,3,6", 30000000))) -data = np.array(data) +sequences = [ + "0,1", + "0,1,2", + "1,2,3", + "3,2,1", + "0,13,16,17,1,10,6", +] +for sequence in sequences: + data = list(map(lambda x: (x[1],len(x[2]),len(x[2])/x[0]), yield_numbers(sequence, 20200))) + data = np.array(data) -plt.plot( - data[:,:2], - linestyle='none', - marker='.', - markersize=1 -) -plt.show() -plt.plot( - data[:,2], - linestyle='none', - marker='.', - markersize=1, - color='g' -) -plt.show() + fig, ax1 = plt.subplots() + ax1.title.set_text(sequence) + ax1.plot( + data[:, :2], + linestyle='none', + marker='.', + markersize=1 + ) + ax2 = ax1.twinx() + ax2.plot( + data[:, 2], + linestyle='none', + marker='.', + markersize=1, + color='r' + ) + ax2.set_yscale('log') + plt.show()