Enigmatic Code

Programming Enigma Puzzles

Puzzle 44: Men-only Mews

From New Scientist #1095, 23rd March 1978 [link]

At the time with which this story deals Alf, Bert, Charlie, Duggie and Ernie were living in separate houses in Men-only Mews.

It is useful for the managing director to know the address of his staff, but I’m afraid this information was not very easy to obtain.

However, I did manage to get some of them to tell me something:

Duggie said that the number of his house was three times the number of Bert’s.

Alf said that his number was odd, and was 23 more than Ernie’s.

Bert said that his number was nine less than Alf’s.

And Charlie said that his number was halfway between Bert’s and Duggie’s.

Men-only Mews has houses numbered from 1-50.

Find the numbers of all their houses.

[puzzle44]

2 responses to “Puzzle 44: Men-only Mews”

1. Jim Randell 18 July 2018 at 9:23 am

This puzzle is straightforward analytically:

Houses are numbered from 1 to 50.

A is an odd-number, 23 more than E, so is limited to: [25, 27, 29, 31, …, 49] (13 possibilities).

And the corresponding values for E are: [2, 4, 6, 8, …, 26].

B is 9 less than A, so can be: [16, 18, 20, 22, …, 40].

And D is 3 times B, so can only be 48 (all other possibilities are more than 50). Giving: D=48, B=16, E=2, A=25.

All that’s left is to find C, which is midway between B and D, so is 32. And, as required, all the numbers are different.

Solution: Alf lives at 25, Bert at 16, Charlie at 32, Duggie at 48, Ernie at 2.

A simple program also finds the solution:

Run: [ @repl.it ]

```from enigma import irange, all_different, printf

# all numbers are from 1 to 50
numbers = set(irange(1, 50))

# consider values for A
for A in numbers:

# A is odd
if not(A % 2 == 1): continue

# A = E + 23
E = A - 23
if not(E in numbers): continue

# B = A - 9
B = A - 9
if not(B in numbers): continue

# D = 3B
D = 3 * B
if not(D in numbers): continue

# C = (B + D) / 2
(C, r) = divmod(B + D, 2)
if not(r == 0 and C in numbers): continue

# and the numbers are all different
if not all_different(A, B, C, D, E): continue

printf("A={A} B={B} C={C} D={D} E={E}")
```
2. geoffrounce 18 July 2018 at 10:19 am
```% A Solution in MiniZinc
include "globals.mzn";

% using A, B, C, D, E for Alf, Bert, Charlie, Duggie and Ernie
var 1..50: A; var 1..50: B; var 1..50: C; var 1..50: D; var 1..50: E;

constraint D == 3 * B /\ (A mod 2 == 1 /\ A - 23 = E) /\ A - 9 == B /\ 2 * C == B + D;

solve satisfy;

output [ "[A, B, C, D, E] = " ++ show([A, B, C, D, E]) ];
% [A, B, C, D, E] = [25, 16, 32, 48, 2]
```

This site uses Akismet to reduce spam. Learn how your comment data is processed.