ILP Part 69 — Krypto 3 po 3

This is the sixtieth ninth part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra

Today we’ll solve Krypto 3 po 3 riddles. With ILP and proper library they can be very readable.

We start with the following:

So we define 9 variables for letters A to I. We make sure their values are different.

Now, riddle 1:

So it took CPLEX 30 milliseconds to find solution. We can also see that we can just read formulas like sentences. Obviously, if we had operator overloading in place then it would be even easier to write. Microsoft Solver Foundation gives you this nice experience.

Riddle 2:

And riddle 3:

Riddle 3 solved with SCIP:

You can see that it took over 20 seconds (I’m using old SCIP, though).

Riddle 3 with Mipcl:

You can see Mipcl finished in 3.5 second.

I also tried GLPK, MSF, lp_solve, and CBC (via OrTools) – none of them could solve the problem is reasonable (< 1 minute) time.