From: anaha@hotmail.com Newsgroups: sci.math Subject: "des chiffres et des lettres" Date: Fri, 29 May 1998 08:05:12 GMT There is a famous game in France called "des chiffres et des lettres", ie. "letters and numbers". The "numbers" part is s follows : seven numbers are chosen at random in the set {1,2,...,9,10, 25, 50, 75, 100} and another number between 1 and 999 is also picked at random. Then we have to obtain this number with the seven others and the four operations, using each number only once. I can not see clearly what mathematics are implied here, and it would bevery nice if someone had an idea of an algorithm to see if there is a solution and generate it. Oh, I forgot : the players have 40 seconds, which is not very long, nd a brutal algorithms would maybe bee to slow. thanks for any suggestion... -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading ============================================================================== From: Torkel Franzen Newsgroups: sci.math Subject: Re: "des chiffres et des lettres" Date: 29 May 1998 11:16:18 +0200 anaha@hotmail.com writes: > seven numbers are chosen at random in the set {1,2,...,9,10, 25, > 50, 75, 100} and another number between 1 and 999 is also picked at > random. > Then we have to obtain this number with the seven others > and the four operations, using each number only once. > ... > Oh, I forgot : the players have 40 seconds, which > is not very long, nd a brutal algorithms would maybe bee to slow. This is the sort of game that should be left to computers: find_expression(L,U,N):- expression(L,U), N is U. expression([X],X):-!. expression(L,U):- pick(X,L,Lrest), expression(Lrest,U1), combine(X,U1,U). combine(X,U1,X*U1). combine(X,U1,X+U1). combine(X,U1,X-U1). combine(X,U1,U1-X). combine(X,U1,X//U1):-W is U1,W\==0,0 is X mod W. combine(X,U1,U1//X):-X\==0,0 is U1 mod X. pick(X,[X|L],L). pick(X,[Y|L],[Y|L1]):- pick(X,L,L1). Example: | ?- find_expression([75,8,3,50,7,4,6],U,393). U = 7*(50+(6+3*4))-8-75 ? yes | ?- find_expression([75,8,3,50,7,4,6],U,45). U = 75-(8+(3+(50-(7+4*6)))) ? yes | ?- find_expression([75,8,3,50,7,4,6],U,1). U = 3+(50+(7+4*6))-8-75 ? yes | ?- find_expression([75,8,3,50,7,4,6],U,783). U = 75+(8-50*(3+(7-4*6))) ? yes