Day 15 (visualize)
This commit is contained in:
@@ -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],
|
||||
fig, ax1 = plt.subplots()
|
||||
ax1.title.set_text(sequence)
|
||||
ax1.plot(
|
||||
data[:, :2],
|
||||
linestyle='none',
|
||||
marker='.',
|
||||
markersize=1
|
||||
)
|
||||
plt.show()
|
||||
plt.plot(
|
||||
data[:,2],
|
||||
)
|
||||
ax2 = ax1.twinx()
|
||||
ax2.plot(
|
||||
data[:, 2],
|
||||
linestyle='none',
|
||||
marker='.',
|
||||
markersize=1,
|
||||
color='g'
|
||||
)
|
||||
plt.show()
|
||||
color='r'
|
||||
)
|
||||
ax2.set_yscale('log')
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user