# Enigmatic Code

Programming Enigma Puzzles

## Tantalizer 492: Bon appetit

From New Scientist #1043, 17th March 1977 [link]

If you ever take a holiday on the little island of Mandible, be sure to sample the local food. The basic element is a squash, called a Tiddly, which sells at KL francs per portion. One of these together with a Widdly and an Om make a satisfying meal for LJ francs. But you do not have to have a Tiddly every time and there is much to be said for having just the Widdly and the Om, in which case the dish will cost JL francs. Yet, the Widdly being a bug-eyed lizard and the Om a fried roll filled with peppered ants, you might do well to order a Pom too, thus raising the cost from JL to KM francs. Finally there is the famous Mandible Monster, which consists quite simply of Tiddly, Widdly, Om and Pom and costs MK francs.

Mandible money is straightforward so I have tried to confuse you by replacing digits with letters. Thus JK means 10×J + K and so on.

My own favourite dish is the Tiddly Om Pom (which I had previously supposed to be the French for a drunken man and an apple). In plain digits, what does it cost, given that a Widdly costs J francs more than an Om?

[tantalizer492]

### 2 responses to “Tantalizer 492: Bon appetit”

1. Jim Randell 25 January 2017 at 9:52 am

We can determine values for a Tiddly, an Om and a Pom and then add them together to get the answer.

Here I’ve used the SubstitutedExpression() solver from the enigma.py library. It runs in 84ms.

#!/usr/bin/env python -m enigma -r

# a Tiddly costs KL
#
# a Widdly and an Om cost JL
# and a Widdly costs J more than an Om,
# so:
#  (om + J) + om = JL
#  om = (JL - J) / 2
#
# a Pom costs KM - JL

# solver to use
SubstitutedExpression

# solver parameters:
# the answer: Tiddly + Om + Pom
--answer="KL + (JL - J) // 2 + KM - JL"

# expressions to solve:

# a Widdly and an Om cost JL
# a Tiddly, Widdly and Om cost LJ
"KL + JL = LJ"

# a Pom costs KM - JL
"KM - JL > 0"

# a Tiddly, Widdly, Om, and Pom cost MK
"LJ + KM - JL = MK"

# a Widdly and an Om cost JL
# and a Widdly costs J more than an Om
"(JL - J) % 2 = 0"

Solution: A Tiddly Om Pom costs 59 francs.

J=2, K=3, L=6, M=7

Tiddly = 36 francs
Widdly = 14 francs
Om = 12 francs
Pom = 11 francs

Tiddly Om Pom = 59 francs

If allow negative prices there is a second solution:

J=6, K=1, L=8, M=3

Tiddly = 18 francs
Widdly = 37 francs
Om = 31 francs
Pom = –55 francs

Tiddly Om Pom = –6 francs

But this is disallowed as we are told adding a Pom raises the price of the dish.

• Jim Randell 25 January 2017 at 2:18 pm

Here’s the problem as a MiniZinc model. This also executes in 83ms.

include "globals.mzn";

var 1..9: J;
var 1..9: K;
var 1..9: L;
var 1..9: M;

constraint all_different([J, K, L, M]);

% a Tiddly costs KL
% a Widdly and an Om cost JL
% a Tiddly, Widdly and Om cost LJ
% so: KL + JL = LJ
constraint 10 * K + 9 * J - 8 * L = 0;

% a Pom costs KM - JL
% so: KM - JL > 0
constraint 10 * (K - J) + M + L > 0;

% a Tiddly, Widdly, Om and Pom cost MK
% LJ + KM - JL = MK
constraint L + K = M + J;

% a Widdly and an Om cost JL
% a Widdly costs J more than an Om
constraint (J + L) mod 2 = 0;

solve satisfy;