This blog article solves a logic riddle from the book “Harry Potter and the Philosopher's Stone” by encoding it as an optimisation problem.
Sadly, the description of the book isn't enough to solve the riddle unambiguously because there are a couple of details missing. However, with a bit of brute-force you can figure out the 42 possible scenarios and with a bit of further deduction, based on the prose of the book, you can narrow it down to 4 possible scenarios.