Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!seismo!hao!hplabs!sri-unix!Suwa@Sumex-AIM From: Suwa@Sumex-AIM@sri-unix.UUCP Newsgroups: net.ai Subject: Puzzle Solution Message-ID: <11952@sri-arpa.UUCP> Date: Mon, 19-Sep-83 05:25:41 EDT Article-I.D.: sri-arpa.11952 Posted: Mon Sep 19 05:25:41 1983 Date-Received: Tue, 27-Sep-83 02:11:38 EDT Lines: 88 From: Motoi Suwa [Reprinted from the Prolog Digest.] Date: 14 Sep. 1983 From: K.Handa ETL Japan Subject: Another Puzzle Solution This is the solution of Alan's puzzle introduced on 24 Aug. ?-go(10). will display the ten disgit number as following: -->6210001000 and ?-go(4). will: -->1210 -->2020 I found following numbers: 6210001000 521001000 42101000 3211000 21200 1210 2020 The Following is the total program ( DEC10 Prolog Ver.3 ) /*** initial assertion ***/ init(D):- ass_xn(D),assert(rest(D)),!. ass_xn(0):- !. ass_xn(D):- D1 is D-1,asserta(x(D1,_)),asserta(n(D1)),ass_xn(D1). /*** main program ***/ go(D):- init(D),guess(D,0). go(_):- abolish(x,2),abolish(n,1),abolish(rest,1). /* guess 'N'th digit */ guess(D,D):- result,!,fail. guess(D,N):- x(N,X),var(X),!,n(Y),N=),n(N),x(N,M),print(M),fail. result:- nl.