Day 15 (visualize)

This commit is contained in:
Sebastian Seedorf
2020-12-16 17:33:29 +01:00
parent 7f821e8d93
commit 2b21efbe67

View File

@@ -2,21 +2,32 @@ from day15.common import yield_numbers
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
import numpy as np 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))) sequences = [
data = np.array(data) "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( fig, ax1 = plt.subplots()
data[:,:2], ax1.title.set_text(sequence)
linestyle='none', ax1.plot(
marker='.', data[:, :2],
markersize=1 linestyle='none',
) marker='.',
plt.show() markersize=1
plt.plot( )
data[:,2], ax2 = ax1.twinx()
linestyle='none', ax2.plot(
marker='.', data[:, 2],
markersize=1, linestyle='none',
color='g' marker='.',
) markersize=1,
plt.show() color='r'
)
ax2.set_yscale('log')
plt.show()