Home

Advent of Code 2023

Advent of Code 2023 I will do this years Advent of Code 2022 in vanilla (only included libraries) python 3.11. I’ve joined the challenge a few times before - but never finished. Let’s see how many days I manage this round :D NOTE: This blog contains spoilers - use it responsibly. I’ve hidden the details for each day behind expand details blo...

Read more

Optimizing matrix multiplication

Introduction I was asked to speed the inner loop that runs many times inside a Markov Chain Monte Carlo. The slowest part of each iteration is taking the product of the Z-scores of a constant matrix, \(X\), and float-valued vectors \(u\) or \(v\). Here, \(X\) is a tall \(n \times m\) matrix with \(n=45000\) and \(m=3\) with all elements in \(...

Read more

Advent of Code 2022

Advent of Code 2022 I will do this years Advent of Code 2022 in vanilla (only included libraries) python 3.10.4. I’ve joined the challenge a few times before - but never finished. Let’s see how many days I manage this round :D NOTE: This blog contains spoilers - use it responsibly. I’ve hidden the details for each day behind expand details bl...

Read more

Fun with fish tiles

The fish tile A fish tile is shown in Figure 1. It is remarkably fun to play with! It is formed by two equilateral pentagons - the regular pentagon head, and the pentagonal crescent tail. The tail opening angle is 108 degrees so it fits a regular pentagon, while the angle between the head and tail is 144 degrees and fits a regular decagon. ...

Read more

Iterating over a parameter space

Introduction I often find myself having to run code for some arbitrary set of different parameters. This can be done with nested for loops. This is not pretty, and poses a challenge for paralleization and progress tracking. In this blog post, I solve this in python with tqdm for progress bars and multiprocess for parallelizing. Weather example...

Read more

Polygon vertices

There are only 21 ways to place regular polygons in gapless tilings. The point where the polygons meet is called a vertex. Vertices are named by the polygons meeting there. For instance, the vertex where four squares meet is 4.4.4.4. In this post, I will make code to find and draw all possible vertices. Regular polygons A regular polygon has $...

Read more

Tree hack - building and printing a tree

In which I made two snippets for my trees. Background Recently, I had to write a python script that transforms incoming data organizsed in a folder structure. For this, I needed both a simple python representation and an easy way to print the data. Consider a project which collects sightings of Bigfoot, Nessie, and Yeti as .csv files for each...

Read more

Exploring repunit digit sum fractions

In which I go down a rabbit hole of integer sequences when trying to understand a pattern in fractions of repeated digits and their digit sums. The tweets This tweet appeared in my Twitter feed: Mathematics and mystery.555, 666, 777, and friends. Source: https://t.co/63RFs36q8S pic.twitter.com/h6gjbIfLK5— Cliff Pickover (@pickover) June...

Read more