My horrifically janky code for the last question of the 2023 MEI Ritangle competition - see the question. Full writeup here.
checker.py is for calculating the detriment for the example in the question (and manually checking certain cases).
The approach is centred around the Gurobi Optimizer and inspired by this project.
Jude Young.