In this post I describe an OpenRules solution to the puzzle offered as DMCommunity.org June-2021 Challenge:
So far there are 12 solutions. In the very first one, Jan Vanthienen found the solution by constructing the corresponding decision tables without necessity to execute them. A trivial (“Common Sense“) solution is offered by Eric Manalac. There is a solution in Scala, but the majority of other solutions are using different optimization (constraint programming) tools that are perfect for logical puzzles like this one. Initially I also sent my solution using JSR331. But after Andrew Macdonald submitted a pure rules-based solution using IBM ODM, I asked myself: “What is the easiest way to do it in OpenRules?” Below is a quick answer.
I decided to run 3 test cases by placing gold in Box 1, 2, or 3 and let rules to check which test produces the result as CONFLICT or SOLUTION. So, I’ve created one Excel file “DecisionModel.xls” with the following tables:
After executing this decision model with OpenRules, I got the following results for each test case:
Thus, only the second test with Gold In Box 2 produced SUCCESS.
It will be even simpler if instead of 3 Boolean variables Gold In Box 1, Gold In Box 2, and Gold In Box 3 I’d use only one Integer variable “Gold In Box” with possible values 1, 2 , or 3.