Pizza, beer, whiskey

edit

After a hard days work, attempting to meet some crazy deadline, with the project from hell, there comes that desperate time at 10 PM when we all need pizza, beer, whiskey. Pizza shops are open at,

 

Beer you can get at,

 

Whiskey,

 

The cops are about and we are not getting any younger. Where to go?

 

If the constraints are applied in the order left to right,

 

Then we need to unify this with,

 

This will create 24 combinations from which the matching ones are,

 

Finally we need to unify with whiskey.

 

Which gives 6 combinations. The matching one is,

 

A total of 30 combinations were generated.

If the constraints are applied in the order right to left,

 

Then we need to unify this with,

 

This will create 8 combinations from which the matching one is,

 

Finally we need to unify with pizza.

 

Which gives 6 combinations. The matching one is,

 

The result is the same but only 14 combinations were generated to arrive at the conclusion.

Every calculation combines value sets to create a value set which is the product of the sizes of the input value sets. The value set will then be trimmed down. And every calculation has an equal chance of narrowing the calculation. So by controlling the order and proceeding with calculations with the smallest product of sizes, there will be less calculation and less combinatorial explosion.