Files
python-aoc-2020/day15/visualize.py
Sebastian Seedorf 2b21efbe67 Day 15 (visualize)
2020-12-16 17:33:29 +01:00

34 lines
697 B
Python

from day15.common import yield_numbers
from matplotlib import pyplot as plt
import numpy as np
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)
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()