Cocktail Optimization, an Integer Programming Problem

Coder’s DIY cocktail picker got crushed by a smarter tool — and the comments got thirsty

TLDR: A programmer learned that modern software can solve a cocktail-planning puzzle in milliseconds, far faster than a homemade approach, finding 29 drinks from 30 ingredients. Commenters turned it into comedy and debate, joking about booze-hoarding apps, questioning reinventing the wheel, and spiraling into French 75 champagne drama.

A programmer proudly revisited an old passion project: a homemade system for figuring out the best set of bar ingredients to maximize how many cocktails you can make. Plot twist: a modern solver from Google’s OR-Tools and glpk.js absolutely wiped the floor with the handcrafted version. What once took minutes — and still kept hunting forever for a better answer — now lands the final result in milliseconds. The big number that set the mood? With 30 ingredients, you can make 29 cocktails.

But the real party happened in the comments, where readers instantly turned this from a math story into a full-on drinks-cabinet soap opera. One fan shouted out Difford’s Guide as the dangerous enabler in the room, joking that it basically gamifies hoarding booze by showing how many drinks you’re just one bottle away from unlocking. Another commenter came in hot with the spiciest take: writing a custom solver in the first place seemed “kind of absurd” when so many free options already exist. And yet — in classic internet fashion — they immediately admitted the story also made them want to build one anyway.

Then came the chaos goblin energy: a commenter derailed the thread to warn that the real problem with a French 75 is being forced to drink too many of them before the champagne goes flat. Technically unrelated? Yes. Deeply relatable? Also yes. So while the article says the machines won, the crowd’s verdict was even better: this was half optimization problem, half accidental lifestyle discourse about collecting liquor, reinventing the wheel, and the practical limits of brunch cocktails.

Key Points

  • The author has previously solved integer programming problems with custom branch-and-bound algorithms.
  • The article compares custom optimization code with modern mixed integer linear programming solvers.
  • The author has been using Google OR-Tools on a vehicle routing project.
  • A previously written cocktail-tray branch-and-bound solver becomes very slow at an ingredient budget of 30.
  • Using glpk.js, the cocktail optimization problem reaches a final optimum in milliseconds, with 29 cocktails possible from 30 ingredients.

Hottest takes

"gamifies your drinks cabinet" — TobyTheCamel
"Writing a custom solver seems kind of absurd to me" — ponco
"you'd have to drink an unhealthy number of them" — mauvehaus
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.