Day 15 (visualisation)

This commit is contained in:
akp 2020-12-15 20:56:30 +00:00
parent fb867cec67
commit fb8e6cf5dc
No known key found for this signature in database
GPG key ID: D3E7EAA31B39637E
5 changed files with 36 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -1,8 +1,14 @@
# [Day 15: Rambunctious Recitation](https://adventofcode.com/2020/day/15)
### Visualisation
| Part one | Part two |
| ------------------------------ | ------------------------------------ |
| ![partOne png](0.png?raw=true) | ![partTwo png](1-hires.png?raw=true) |
### Related
* [Numberphile - Don't Know (the Van Eck Sequence)](https://www.youtube.com/watch?v=etMJxB-igrc)
- [Numberphile - Don't Know (the Van Eck Sequence)](https://www.youtube.com/watch?v=etMJxB-igrc)
<details><summary>Script output</summary>

View file

@ -0,0 +1,29 @@
import common
import matplotlib.pyplot as plt
from typing import List
def make_graph(data:List[int], n:int):
line_colour = "#3572a5"
plt.plot(list(range(len(data))), data, color=line_colour)
plt.title(f"AoC 2020, day 15 part {n}")
plt.xlabel("Iteration number")
plt.ylabel("Value")
def visualise(instr:str):
print("Running part one...")
_, one = common.find_value_n(instr, 2020)
print("Making graph")
make_graph(one, 1)
print("Saving")
plt.savefig("0.png")
plt.clf()
print("Running part two...")
_, two = common.find_value_n(instr, 30000000)
print("Making graph")
make_graph(two, 2)
print("Saving low resolution")
plt.savefig("1-lores.png")
print("Saving high resolution")
fig = plt.gcf()
fig.set_size_inches(20.48, 10.8)
fig.savefig('1-hires.png', dpi=100)