Module day13

Source
Expand description

§Claw Contraption

Each claw machine is a system of two linear equations:

    (Button A X) * (A presses) + (Button B X) * (B presses) = Prize X
    (Button A Y) * (A presses) + (Button B Y) * (B presses) = Prize Y

Shortening the names and representing as a matrix:

    [ ax bx ][ a ] = [ px ]
    [ ay by ][ b ] = [ py ]

To solve we invert the 2 x 2 matrix then premultiply the right column.

Functions§

parse
part1
part2
play 🔒
Invert the 2 x 2 matrix representing the system of linear equations.

Type Aliases§

Claw 🔒