mathspp
  • Blog
    • Pydon'ts
    • Problems
    • TIL
    • Twitter threads
  • Books
  • Talks
  • Trainings
    • Advanced iteration
    • Python for scripting and automation
    • Rust for Python developers
  • Courses
  • About
Link blog

Magical optimization for optimization muggles

by Tim Varelmann on 09-02-2026 17:00

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.

Previous link Next link

Russian mathematician Grigori Perelman declined a $1,000,000 prize after solving one of the seven Millenium Prize Problems.

mathspp
  • Blog
    • Pydon'ts
    • Problems
    • TIL
    • Twitter threads
  • Books
  • Talks
  • Trainings
    • Advanced iteration
    • Python for scripting and automation
    • Rust for Python developers
  • Courses
  • About