Module aoc::year2015::day13

source ·
Expand description

§Knights of the Dinner Table

This problem is very similar to Day 9 and we solve it in almost exactly the same way by computing an adjacency matrix of happiness then permuting the order of the diners.

For part one we reduce the permutatations from 8! = 40,320 permutations to 7! = 5,040 permutations by arbitrarily choosing one of the diners as the start.

We solve part two at the same time by noticing that by inserting yourself between two diners you set the value of their mutual link to zero. Keeping tracking of the weakest link then subtracting that from the value for part one gives the result for part two at almost no additional cost.

Functions§

Type Aliases§