[Ť @@@@@@@@@@@2000.11.22@deepgreen s % c:/prolog/srclib/pegsolitia/peg21ida2.pl compiled 0.00 sec, 9,204 bytes ?- q. searching(1) [time, 0.11] [count, 0] searching(2) [time, 0.11] [count, 0] searching(3) [time, 0.11] [count, 0] searching(4) [time, 0.11] [count, 0] searching(5) [time, 0.11] [count, 0] searching(6) [time, 0.11] [count, 0] searching(7) [time, 0.11] [count, 0] searching(8) [time, 0.11] [count, 0] searching(9) [time, 0.17] [count, 10] searching(10) [time, 12.47] [count, 4331] searching(11) ....... congratulation !! 92 : [7, 18, 11, 9, 15, 6, 3, 8, 5, 21, 3, 4, 10, 12, 7, 16, 11, 10] congratulation !! 93 : [7, 18, 11, 9, 15, 6, 8, 3, 5, 3, 21, 4, 10, 12, 7, 16, 11, 10] congratulation !! 94 : [7, 18, 11, 9, 15, 6, 3, 8, 5, 3, 21, 4, 10, 12, 7, 16, 11, 10] congratulation !! 95 : [7, 18, 11, 9, 15, 6, 8, 3, 5, 3, 4, 21, 10, 12, 7, 16, 11, 10] congratulation !! 96 : [7, 18, 11, 9, 15, 6, 3, 8, 5, 3, 4, 21, 10, 12, 7, 16, 11, 10] [time, 2383.5] [count, 1083994] time[3.25, 2386.75, 2383.5] Yes ?- vO % PegSolitia 2000.11.22 deepgreen % % 1 2 % 3 % 4 5 % 6 7 8 % 9 a b c % d f g h i l j % e k triple( 1, 3, 5). triple( 2, 3, 4). triple( 3, 4, 6). triple( 3, 5, 8). triple( 4, 6, 9). triple( 4, 7,11). triple( 5, 7,10). triple( 5, 8,12). triple( 6, 9,15). triple( 6,10,17). triple( 6, 7, 8). triple( 7,10,16). triple( 7,11,18). triple( 8,11,17). triple( 8,12,21). triple( 9,15,14). triple( 9,10,11). triple(10,11,12). triple(12,21,20). triple(13,15,16). triple(15,16,17). triple(16,17,18). triple(17,18,21). triple(18,21,19). % (C,B,A) must need lbound(0,0,0). lbound(1,1,1). lbound(2,1,1). lbound(3,2,2). lbound(4,1,-1). lbound(5,1,0). lbound(6,1,0). lbound(7,2,1). pegsearch(Hand,Max,Map) :- search(Hand,Max,Map,0,[]) ; !. search(Hand,Max,Map,Lop,LL) :- Hand =< Max, % format(' Hand : ~d',Hand), % format(' Max:~d',Max), % format(' Lop :~d',Lop), % format(' Map :~16r ',Map),nl, path(P,Q,Map,Nmap), (P =:= Lop -> H is Hand ; H is Hand + 1), lbCheck(H,Max,Nmap,Q), goalcheck(Nmap,[Q|LL]), search(H,Max,Nmap,Q,[Q|LL]). lbCheck(Hand,Max,Map,P) :- ((0x228148 /\ (1< (Nmap is Map, D is 0) ; (Nmap is Map xor (1<> 1) /\ 7,lbound(A,Am,An), B is (Nmap>>13) /\ 7,lbound(B,Bm,Bn), C is (Nmap>>19) /\ 7,lbound(C,Cm,Cn), E is An + Bn + Cn + D, Need is max(E,0), Must is Am + Bm + Cm, (Hand + Must + Need) =< Max,!. goalcheck(0x80,L) :- % Map =:= 0x80, flag(ans,A,A+1),AA is A+1, format(' congratulation !! ~d : ',AA),print(L),nl,!,fail. goalcheck(Map,L) :- % print(Map),tab(2),format('~16r',Map),nl, Map =\= 0x80, flag(count,C,C+1),!. pathgen :- triple(A,B,C), ABC is (1<