Advent of Code 2023 - Day 4: Scratchcards

:: programming, puzzle, racket

1
2
#lang iracket/lang #:require racket
(require "../advent.rkt")

I always enjoy recursive list processing in Racket :) Here’s our input today:

Card 1: 41 48 83 86 17 | 83 86  6 31 17  9 48 53
Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
Card 3:  1 21 53 59 44 | 69 82 63 72 16 21 14  1
Card 4: 41 92 73 84 69 | 59 84 76 51 58  5 54 83
Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11

Advent of Code 2023 - Day 2: Cube Conundrum

:: programming, puzzle, racket

1
2
#lang iracket/lang #:require racket
(require "../advent.rkt" threading)

Our data today is as follows:

Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green

For today’s task, I found it helpful to make use of the parallel-combine combinator from Hanson & Sussman’s “Software Design for Flexibility”. This combinator applies f and g to the input, in parallel, and combines their output using h. Pictorially, it looks like this:

Upgrading to Emacs 29.1

:: emacs

It appears upgrading my Anaconda Python distribution killed my Emacs, so I figured I’d try upgrading to the latest version to see if that fixed things. It did :)

Since upgrading Emacs to 29.1 no longer required the manual configuration changes I had to make when upgrading to 28.2, I’ll document the procedure I used on MacOS Ventura 13.6.1

Advent of Code 2022 - Day 5: Supply Stacks

:: programming, puzzle, racket

1
2
#lang iracket/lang #:require racket
(require "../advent.rkt")

Day 5 - Part 1

Supply Stacks We’re given the following sample input:

    [D]    
[N] [C]    
[Z] [M] [P]
 1   2   3 

move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2

And, fortunately for us, the first part has lines padded with spaces to be of equal length - this makes parsing just a little bit easier :) Even so, the built-in parsers we have for AoC are insufficient, so we’ll just use a custom parser that reads the file into a string, splits it on "\n\n", and then maps the string-split function over both parts - the stack lines and the command lines: