AoC 2022 Day 10: Interpretator

Source: Cathode-Ray Tube

Part 1

Implement a simple virtual machine with two instructions: nop which does nothing for 1 cycles and addx $n which adds $n to the X register (initial value 1) in two cycles. Calculate the sum of cycle * X for the cycles 20, 60, 100, 140, 180, 220.


AoC 2022 Day 9: Ropeinator

Source: Rope Bridge

Part 1

Simulate two connected links such that whenever the first link (head) moves, the tail moves to follow according to the following rules:

  • If the tail is at the same location as head, don’t move
  • If the tail is adjacent to the head (orthogonal or diagonal), don’t move
  • If the tail is in the same row/column as the head, move one directly towards it orthogonally
  • If the tail is in neither the same row nor column, move one towards diagonally

Count how many unique spaces are visited by the tail of the link.


Splitting Images

I recently came across a problem where I had a single image with a transparent background containing multiple images that I wanted to split into their component parts. For example, split this:

Into these:



Perhaps the best known fractal of all: the Mandelbrot set.

Since I was already working on Python code that would render an image given a function (for a future post), I figured that I might as well render fractals with it.


Tupper's self-referential formula

Quick post today. Let’s implement Tupper's self-referential formula in Racket!

\frac{1}{2} < \left \lfloor mod \left ( \left \lfloor \frac{y}{17} 2^{-17 \lfloor x \rfloor - mod(\lfloor y \rfloor, 2)} \right \rfloor, 2 \right ) \right \rfloor
(tupper 960939379918958884971672962127852754715004339660129306651505519271702802395266424689642842174350718121267153782770623355993237280874144307891325963941337723487857735749823926629715517173716995165232890538221612403238855866184013235585136048828693337902491454229288667081096184496091705183454067827731551705405381627380967602565625016981482083418783163849115590225610003652351370343874461848378737238198224849863465033159410054974700593138339226497249461751545728366702369745461014655997933798537483143786841806593422227898388722980000748404719)

That’s the result of graphing the above function at a point rather far away from the origin. Specifically, where y is around that crazy big number. Look familiar?