Delmatic interview question

Solve example problem from the past Advent of Code.