Newsgroups: comp.ai
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!gatech!bloom-beacon.mit.edu!spool.mu.edu!cass.ma02.bull.com!as02.bull.oz.au!melb.bull.oz.au!bkr
From: bkr@melb.bull.oz.au (Bret Krieger)
Subject: Re: Riddle to solve: Safe combination
Message-ID: <bkr.801375023@pandora.melb.bull.oz.au>
Sender: news@as03.bull.oz.au (USENET News Account)
Nntp-Posting-Host: pandora.as03.bull.oz.au
Organization: Bull HN Information Systems Australia.
References: <3pqc0t$e22@p235.informatik.uni-Bremen.de>
Date: Thu, 25 May 1995 04:10:23 GMT
Lines: 84

Christoph Ranze <kcr@informatik.uni-bremen.de> writes:

>-- 
>Dear colleagues,

>here is a riddle to solve!



>Safe combination
>----------------

>Professor Wirbel has got a new safe but he could not make a note of figures. 
>He is afraid of writing down the safe combination. Therefore he encodes the 
>combination with an arithmetic riddle:

>1. The safe combination contains nine numbers.
>2. Every number from 1 to 9 appears exactly once.
>3. Number 1 is not the first digit, number 2 not the second digit and so on.
>4. The difference between the fourth digit and the sixth digit equals the 
>seventh digit.
>5. The sum of the second and the sixth digit equals the the sum of the third 
>and the seventh digit.
>6. The product of the first three digit equals the sum of the last two digits.

>How can you ascertain the combination? There is only one solution.

>The interesting point is:
>Is there any chance to solve the riddle using constraints? 
>We are of the opinion that there is no way! 
>Any suggestions are welcome! 

Christoph,

the following is a solution to the problem written in the Charme
constraint programming language developed by Bull IS. Processing 
time is negligible. I have quickly hand-tested the result and all 
appears okay. My only problem is that there appears to be two
results! Have I misunderstood the problem?

{
array Num::[1..9] of 1..9;
local X,Y;
all_diff(Num);
for I in 1..9 do
        Num[I] != I;
Num[2]+Num[6]=Num[3]+Num[7];
prod(Num[1..3],Num[8]+Num[9]);
{ {Num[4]-Num[6]=Num[7];} or
{Num[6]-Num[4]=Num[7];} };
generate Num;
print Num;
}

The line containing 'prod' can be replaced by

X=Num[1]*Num[2]; X*Num[3]=Num[8]+Num[9];

result 1: [7,1,2,9,3,5,4,6,8]
result 2: [5,3,1,6,9,2,4,7,8]

>This was a riddle written by Natalie van Eijk in "Spektrum der Wissenschaften".


>Greetings 
>C.Ranze



>************************** ADDRESS **********************************
>:K.Christoph Ranze               EMail:  kcr@informatik.uni-bremen.de
>:Department of Computer Science  Tel.: +49-421-218-7282 /-7090   
>:Artificial Intelligence Group   Fax:  +49-421-218-7196
>:Bremen University               
>:PO Box 330 440   
>:D - 28334 Bremen   
>:http://www.informatik.uni-bremen.de/grp/ag-ki/ag-ki.html
>*********************************************************************
>*	Get on your marks!		*
>*	The future has already begun	*
>*****************************************

Brett Krieger
bkr@melb.bull.oz.au
