-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoursework.pl
More file actions
285 lines (234 loc) · 35.2 KB
/
Coursework.pl
File metadata and controls
285 lines (234 loc) · 35.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/* <Username: jat52 Name:James Treasure>
THIS WORK IS ENTIRELY MY OWN.
The program does not produce multiple answers.
I have not used built-ins.
1. <Number of elements in the list binding Q after executing s1(Q,100) is 1747>
<First I make a list of every potential quad before anything at all has been said.
Remove unique products>
2. <Number of elements in the list binding Q after executing s2(Q,100) is 145>
<Generate a list of numbers that S must be. Remove any quad where S is not in
that list. Sort the list using merge sort so that the list is ordered in
ascending values of P>
3. <Number of elements in the list binding Q after executing s3(Q,100) is 86>
<Remove duplicate producuts. Sort the list using merge sort so that the list
is ordered in ascending values of S>
4.
<Remove duplicate sums leaving the final answer.>
5. <Number of elements in the list binding Q after executing s4(Q,500) is 1>
s4(Q,500) uses 7,629,274,328 inferences. */
%------s1------
get_quads(MaxSum, Result) :-
MaxSum> 1,
get_quads(2, MaxSum, 2, Result).
get_quads(Sum, Sum, Sum, []). % 'Sum' has reached max value
get_quads(Sum, MaxSum, Sum, Result) :-
Sum < MaxSum,
Sum1 is Sum + 1,
get_quads(Sum1, MaxSum, 2, Result). %3,100,1,Result
get_quads(Sum, MaxSum, X, [[X, Y, Sum, P]|Result]) :-
Sum =< MaxSum,
X < Sum,
Y is Sum - X,
X < Y,
P is X*Y,
X1 is X + 1,
get_quads(Sum, MaxSum, X1, Result).
get_quads(Sum, MaxSum, X, Result) :-
X1 is X + 1,
get_quads(Sum, MaxSum, X1, Result).
fourth([_,_,_,F|_], F).
get_fourth([], _, 0).
get_fourth([H|T], X, R) :-
fourth(H, X),!,
get_fourth(T, X, RR),
R is RR + 1.
get_fourth([_|T], X, R) :-
get_fourth(T, X, R).
remove_unique([], [], _).
remove_unique([H|T], [H|R], A) :-
fourth(H, X),
get_fourth(A, X, C),
C > 1,
remove_unique(T, R, A).
remove_unique([_|T], R, A) :-
remove_unique(T, R, A).
remove_unique(L, R) :-
remove_unique(L, R, L), !.
s1(Q,N):-
get_quads(N,Numbers), !,
remove_unique(Numbers,Q).
%------s2------
prime(2).
prime(N) :-
sqrt(N,S),
check(N,S,3).
check(_,S,D) :- D>S.
check(N,S,D) :-
N =\= D*(N//D),
D1 is D+2,
check(N,S,D1).
prime_list(B,L) :-
prime_list(2,B,L).
prime_list(A,B,[]) :-
A > B,
!.
prime_list(A,B,[A|L]) :-
prime(A),
!,
next(A,A1),
prime_list(A1,B,L).
prime_list(A,B,L) :-
next(A,A1),
prime_list(A1,B,L).
next(2,3) :- !.
next(A,A1) :- A1 is A + 2.
add_to_list([],[]).
add_to_list([H|T],[Y|List]):-
Y is H + 2,
add_to_list(T,List).
remove_even([],[]).
remove_even([H|T], R):-
H mod 2 =:= 0,
remove_even(T, R).
remove_even([H|T1], [H|T2]):-
remove_even(T1, T2).
generateNumbers(0,[]).
generateNumbers(N,[Head|Tail]):-
N > 0, %N must be greater than 0. Base case.
Head is N, %Sets the head of list to N
N1 is N-1, %Decrements N by 1
generateNumbers(N1,Tail). %Recurses on generateNumbers
mysubtract([], _, []).
mysubtract([Head|Tail], L2, L3) :-
member(Head, L2),
!,
mysubtract(Tail, L2, L3).
mysubtract([Head|Tail1], L2, [Head|Tail3]) :-
mysubtract(Tail1, L2, Tail3).
remove_greater([],[]).
remove_greater([H|T],[H|List]):-
H < 55,
H \= 51,
remove_greater(T,List).
remove_greater([_|T],List):-
remove_greater(T,List).
not_member(_,[]).
not_member(Element,[H|Tail]) :-
Element \= H,
not_member(Element, Tail),!.
member_third(H,List):-
third(H,Third),
not_member(Third,List).
s2_remove([],_,[]).
s2_remove([H|T], TheList, Result) :-
member_third(H, TheList),
s2_remove(T, TheList, Result),!.
s2_remove([A|T], TheList, [A|Result]) :-
s2_remove(T, TheList, Result).
split_list([], [], []).
split_list([A], [A], []).
split_list([A, B|T], [A|Ta], [B|Tb]) :-
split_list(T, Ta, Tb).
merge_by_product(A, [], A).
merge_by_product([], A, A).
merge_by_product([A|Ta], [B|Tb], [A|S]) :-
A = [_, _, _, P1],
B = [_, _, _, P2],
P1 =< P2,
merge_by_product(Ta, [B|Tb], S).
merge_by_product([A|Ta], [B|Tb], [B|S]) :-
A = [_, _, _, P1],
B = [_, _, _, P2],
P1 > P2,
merge_by_product([A|Ta], Tb, S).
sort_by_product([], []).
sort_by_product([A], [A]).
sort_by_product([A, B|T], S) :-
split_list([A, B|T], L1, L2),
sort_by_product(L1, S1),
sort_by_product(L2, S2),
merge_by_product(S1, S2, S).
s2(Q,End):-
generateNumbers(End,Numbers),
remove_greater(Numbers,RemovedNumbers),
prime_list(End,Primes),
remove_greater(Primes,RemovedPrimes),
add_to_list(RemovedPrimes,NewList),
mysubtract(RemovedNumbers,NewList,SubList),
remove_even(SubList,SPossible),
s1(S1,End),
s2_remove(S1,SPossible,AA),!,
sort_by_product(AA,Q),!.
%------s3------
remove_duplicte_products([], [], _).
remove_duplicte_products([H|T], [H|R], A) :-
last(H, X),
get_fourth(A, X, C),
C =:= 1,
remove_duplicte_products(T, R, A).
remove_duplicte_products([_|T], R, A) :-
remove_duplicte_products(T, R, A).
remove_duplicte_products(L, R) :-
remove_duplicte_products(L, R, L), !.
merge_by_sum(A, [], A).
merge_by_sum([], A, A).
merge_by_sum([A|Ta], [B|Tb], [A|S]) :-
A = [_, _, S1, _],
B = [_, _, S2, _],
S1 =< S2,
merge_by_sum(Ta, [B|Tb], S).
merge_by_sum([A|Ta], [B|Tb], [B|S]) :-
A = [_, _, S1, _],
B = [_, _, S2, _],
S1 > S2,
merge_by_sum([A|Ta], Tb, S).
sort_by_sum([], []).
sort_by_sum([A], [A]).
sort_by_sum([A, B|T], S) :-
split_list([A, B|T], L1, L2),
sort_by_sum(L1, S1),
sort_by_sum(L2, S2),
merge_by_sum(S1, S2, S).
s3(Q,N):-
s2(Result,N),
remove_duplicte_products(Result,AA),!,
sort_by_sum(AA,Q),!.
%------s4------
third([_,_,Third|_], Third).
get_third([], _, 0).
get_third([H|T], X, R) :-
third(H, X),!,
get_third(T, X, RR),
R is RR + 1.
get_third([_|T], X, R) :-
get_third(T, X, R).
remove_duplicate_sums([], [], _).
remove_duplicate_sums([H|T], [H|R], A) :-
third(H, X),
get_third(A, X, C),
C =:= 1,
remove_duplicate_sums(T, R, A).
remove_duplicate_sums([_|T], R, A) :-
remove_duplicate_sums(T, R, A).
remove_duplicate_sums(L, R) :-
remove_duplicate_sums(L, R, L), !.
s4(Q,N):-
s3(Result,N),!,
remove_duplicate_sums(Result,Q).
/*
?- consult('jat52.pl').
% jat52.pl compiled 0.01 sec, 76 clauses
true.
?- time(s1(Q,100)).
% 11,107,031 inferences, 1.701 CPU in 1.731 seconds (98% CPU, 6528885 Lips)
Q = [[3,4,7,12],[2,6,8,12],[3,6,9,18],[4,5,9,20],[4,6,10,24],[2,9,11,18],[3,8,11,24],[4,7,11,28],[5,6,11,30],[2,10,12,20],[4,8,12,32],[3,10,13,30],[4,9,13,36],[5,8,13,40],[6,7,13,42],[2,12,14,24],[4,10,14,40],[5,9,14,45],[6,8,14,48],[3,12,15,36],[4,11,15,44],[5,10,15,50],[6,9,15,54],[7,8,15,56],[2,14,16,28],[4,12,16,48],[6,10,16,60],[7,9,16,63],[2,15,17,30],[3,14,17,42],[4,13,17,52],[5,12,17,60],[6,11,17,66],[7,10,17,70],[8,9,17,72],[2,16,18,32],[3,15,18,45],[4,14,18,56],[6,12,18,72],[8,10,18,80],[3,16,19,48],[4,15,19,60],[5,14,19,70],[6,13,19,78],[7,12,19,84],[8,11,19,88],[9,10,19,90],[2,18,20,36],[4,16,20,64],[5,15,20,75],[6,14,20,84],[8,12,20,96],[9,11,20,99],[3,18,21,54],[4,17,21,68],[5,16,21,80],[6,15,21,90],[7,14,21,98],[8,13,21,104],[9,12,21,108],[10,11,21,110],[2,20,22,40],[4,18,22,72],[6,16,22,96],[7,15,22,105],[8,14,22,112],[9,13,22,117],[10,12,22,120],[2,21,23,42],[3,20,23,60],[4,19,23,76],[5,18,23,90],[6,17,23,102],[7,16,23,112],[8,15,23,120],[9,14,23,126],[10,13,23,130],[11,12,23,132],[2,22,24,44],[3,21,24,63],[4,20,24,80],[6,18,24,108],[8,16,24,128],[9,15,24,135],[10,14,24,140],[3,22,25,66],[4,21,25,84],[5,20,25,100],[6,19,25,114],[7,18,25,126],[8,17,25,136],[9,16,25,144],[10,15,25,150],[11,14,25,154],[12,13,25,156],[2,24,26,48],[4,22,26,88],[5,21,26,105],[6,20,26,120],[8,18,26,144],[9,17,26,153],[10,16,26,160],[11,15,26,165],[12,14,26,168],[2,25,27,50],[3,24,27,72],[4,23,27,92],[5,22,27,110],[6,21,27,126],[7,20,27,140],[8,19,27,152],[9,18,27,162],[10,17,27,170],[11,16,27,176],[12,15,27,180],[13,14,27,182],[2,26,28,52],[3,25,28,75],[4,24,28,96],[6,22,28,132],[7,21,28,147],[8,20,28,160],[9,19,28,171],[10,18,28,180],[12,16,28,192],[13,15,28,195],[2,27,29,54],[3,26,29,78],[4,25,29,100],[5,24,29,120],[6,23,29,138],[7,22,29,154],[8,21,29,168],[9,20,29,180],[10,19,29,190],[11,18,29,198],[12,17,29,204],[13,16,29,208],[14,15,29,210],[2,28,30,56],[4,26,30,104],[6,24,30,144],[8,22,30,176],[9,21,30,189],[10,20,30,200],[12,18,30,216],[14,16,30,224],[3,28,31,84],[4,27,31,108],[5,26,31,130],[6,25,31,150],[7,24,31,168],[8,23,31,184],[9,22,31,198],[10,21,31,210],[11,20,31,220],[12,19,31,228],[13,18,31,234],[14,17,31,238],[15,16,31,240],[2,30,32,60],[4,28,32,112],[5,27,32,135],[6,26,32,156],[7,25,32,175],[8,24,32,192],[9,23,32,207],[10,22,32,220],[11,21,32,231],[12,20,32,240],[14,18,32,252],[15,17,32,255],[3,30,33,90],[4,29,33,116],[5,28,33,140],[6,27,33,162],[7,26,33,182],[8,25,33,200],[9,24,33,216],[10,23,33,230],[12,21,33,252],[13,20,33,260],[14,19,33,266],[15,18,33,270],[16,17,33,272],[2,32,34,64],[4,30,34,120],[6,28,34,168],[7,27,34,189],[8,26,34,208],[9,25,34,225],[10,24,34,240],[12,22,34,264],[13,21,34,273],[14,20,34,280],[15,19,34,285],[16,18,34,288],[2,33,35,66],[3,32,35,96],[4,31,35,124],[5,30,35,150],[6,29,35,174],[7,28,35,196],[8,27,35,216],[9,26,35,234],[10,25,35,250],[11,24,35,264],[12,23,35,276],[13,22,35,286],[14,21,35,294],[15,20,35,300],[16,19,35,304],[17,18,35,306],[2,34,36,68],[3,33,36,99],[4,32,36,128],[6,30,36,180],[8,28,36,224],[9,27,36,243],[10,26,36,260],[11,25,36,275],[12,24,36,288],[14,22,36,308],[15,21,36,315],[16,20,36,320],[2,35,37,70],[3,34,37,102],[4,33,37,132],[5,32,37,160],[6,31,37,186],[7,30,37,210],[8,29,37,232],[9,28,37,252],[10,27,37,270],[11,26,37,286],[12,25,37,300],[13,24,37,312],[14,23,37,322],[15,22,37,330],[16,21,37,336],[17,20,37,340],[18,19,37,342],[2,36,38,72],[3,35,38,105],[4,34,38,136],[5,33,38,165],[6,32,38,192],[8,30,38,240],[9,29,38,261],[10,28,38,280],[11,27,38,297],[12,26,38,312],[13,25,38,325],[14,24,38,336],[15,23,38,345],[16,22,38,352],[17,21,38,357],[18,20,38,360],[3,36,39,108],[4,35,39,140],[5,34,39,170],[6,33,39,198],[7,32,39,224],[8,31,39,248],[9,30,39,270],[10,29,39,290],[11,28,39,308],[12,27,39,324],[14,25,39,350],[15,24,39,360],[16,23,39,368],[17,22,39,374],[18,21,39,378],[19,20,39,380],[2,38,40,76],[4,36,40,144],[5,35,40,175],[6,34,40,204],[7,33,40,231],[8,32,40,256],[9,31,40,279],[10,30,40,300],[12,28,40,336],[13,27,40,351],[14,26,40,364],[15,25,40,375],[16,24,40,384],[18,22,40,396],[19,21,40,399],[2,39,41,78],[3,38,41,114],[4,37,41,148],[5,36,41,180],[6,35,41,210],[7,34,41,238],[8,33,41,264],[9,32,41,288],[10,31,41,310],[11,30,41,330],[12,29,41,348],[13,28,41,364],[14,27,41,378],[15,26,41,390],[16,25,41,400],[17,24,41,408],[18,23,41,414],[19,22,41,418],[20,21,41,420],[2,40,42,80],[3,39,42,117],[4,38,42,152],[6,36,42,216],[7,35,42,245],[8,34,42,272],[9,33,42,297],[10,32,42,320],[12,30,42,360],[14,28,42,392],[15,27,42,405],[16,26,42,416],[17,25,42,425],[18,24,42,432],[20,22,42,440],[3,40,43,120],[4,39,43,156],[5,38,43,190],[6,37,43,222],[7,36,43,252],[8,35,43,280],[9,34,43,306],[10,33,43,330],[11,32,43,352],[12,31,43,372],[13,30,43,390],[14,29,43,406],[15,28,43,420],[16,27,43,432],[17,26,43,442],[18,25,43,450],[19,24,43,456],[20,23,43,460],[21,22,43,462],[2,42,44,84],[4,40,44,160],[5,39,44,195],[6,38,44,228],[8,36,44,288],[9,35,44,315],[10,34,44,340],[12,32,44,384],[14,30,44,420],[15,29,44,435],[16,28,44,448],[17,27,44,459],[18,26,44,468],[19,25,44,475],[20,24,44,480],[21,23,44,483],[3,42,45,126],[4,41,45,164],[5,40,45,200],[6,39,45,234],[7,38,45,266],[8,37,45,296],[9,36,45,324],[10,35,45,350],[11,34,45,374],[12,33,45,396],[13,32,45,416],[14,31,45,434],[15,30,45,450],[16,29,45,464],[17,28,45,476],[18,27,45,486],[19,26,45,494],[20,25,45,500],[21,24,45,504],[22,23,45,506],[2,44,46,88],[4,42,46,168],[6,40,46,240],[7,39,46,273],[8,38,46,304],[10,36,46,360],[11,35,46,385],[12,34,46,408],[13,33,46,429],[14,32,46,448],[15,31,46,465],[16,30,46,480],[18,28,46,504],[19,27,46,513],[20,26,46,520],[21,25,46,525],[22,24,46,528],[2,45,47,90],[3,44,47,132],[4,43,47,172],[5,42,47,210],[6,41,47,246],[7,40,47,280],[8,39,47,312],[9,38,47,342],[10,37,47,370],[11,36,47,396],[12,35,47,420],[13,34,47,442],[14,33,47,462],[15,32,47,480],[16,31,47,496],[17,30,47,510],[18,29,47,522],[19,28,47,532],[20,27,47,540],[21,26,47,546],[22,25,47,550],[23,24,47,552],[2,46,48,92],[3,45,48,135],[4,44,48,176],[6,42,48,252],[8,40,48,320],[9,39,48,351],[10,38,48,380],[12,36,48,432],[13,35,48,455],[14,34,48,476],[15,33,48,495],[16,32,48,512],[18,30,48,540],[20,28,48,560],[21,27,48,567],[22,26,48,572],[3,46,49,138],[4,45,49,180],[5,44,49,220],[6,43,49,258],[7,42,49,294],[8,41,49,328],[9,40,49,360],[10,39,49,390],[11,38,49,418],[12,37,49,444],[13,36,49,468],[14,35,49,490],[15,34,49,510],[16,33,49,528],[17,32,49,544],[18,31,49,558],[19,30,49,570],[20,29,49,580],[21,28,49,588],[22,27,49,594],[23,26,49,598],[24,25,49,600],[2,48,50,96],[4,46,50,184],[5,45,50,225],[6,44,50,264],[8,42,50,336],[10,40,50,400],[11,39,50,429],[12,38,50,456],[14,36,50,504],[15,35,50,525],[16,34,50,544],[17,33,50,561],[18,32,50,576],[20,30,50,600],[21,29,50,609],[22,28,50,616],[23,27,50,621],[24,26,50,624],[2,49,51,98],[3,48,51,144],[4,47,51,188],[5,46,51,230],[6,45,51,270],[7,44,51,308],[8,43,51,344],[9,42,51,378],[10,41,51,410],[11,40,51,440],[12,39,51,468],[13,38,51,494],[14,37,51,518],[15,36,51,540],[16,35,51,560],[18,33,51,594],[19,32,51,608],[20,31,51,620],[21,30,51,630],[22,29,51,638],[23,28,51,644],[24,27,51,648],[25,26,51,650],[2,50,52,100],[3,49,52,147],[4,48,52,192],[6,46,52,276],[7,45,52,315],[8,44,52,352],[10,42,52,420],[12,40,52,480],[14,38,52,532],[16,36,52,576],[17,35,52,595],[18,34,52,612],[19,33,52,627],[20,32,52,640],[21,31,52,651],[22,30,52,660],[24,28,52,672],[25,27,52,675],[2,51,53,102],[3,50,53,150],[4,49,53,196],[5,48,53,240],[6,47,53,282],[7,46,53,322],[8,45,53,360],[9,44,53,396],[10,43,53,430],[11,42,53,462],[12,41,53,492],[13,40,53,520],[14,39,53,546],[15,38,53,570],[16,37,53,592],[17,36,53,612],[18,35,53,630],[19,34,53,646],[20,33,53,660],[21,32,53,672],[22,31,53,682],[23,30,53,690],[24,29,53,696],[25,28,53,700],[26,27,53,702],[2,52,54,104],[3,51,54,153],[4,50,54,200],[5,49,54,245],[6,48,54,288],[8,46,54,368],[9,45,54,405],[10,44,54,440],[12,42,54,504],[14,40,54,560],[15,39,54,585],[16,38,54,608],[18,36,54,648],[20,34,54,680],[21,33,54,693],[22,32,54,704],[24,30,54,720],[26,28,54,728],[3,52,55,156],[4,51,55,204],[5,50,55,250],[6,49,55,294],[7,48,55,336],[8,47,55,376],[9,46,55,414],[10,45,55,450],[12,43,55,516],[13,42,55,546],[14,41,55,574],[15,40,55,600],[16,39,55,624],[17,38,55,646],[18,37,55,666],[19,36,55,684],[20,35,55,700],[21,34,55,714],[22,33,55,726],[23,32,55,736],[24,31,55,744],[25,30,55,750],[26,29,55,754],[27,28,55,756],[2,54,56,108],[4,52,56,208],[5,51,56,255],[6,50,56,300],[8,48,56,384],[10,46,56,460],[11,45,56,495],[12,44,56,528],[14,42,56,588],[16,40,56,640],[17,39,56,663],[18,38,56,684],[20,36,56,720],[21,35,56,735],[22,34,56,748],[23,33,56,759],[24,32,56,768],[26,30,56,780],[27,29,56,783],[2,55,57,110],[3,54,57,162],[5,52,57,260],[6,51,57,306],[7,50,57,350],[8,49,57,392],[9,48,57,432],[10,47,57,470],[11,46,57,506],[12,45,57,540],[13,44,57,572],[14,43,57,602],[15,42,57,630],[16,41,57,656],[17,40,57,680],[18,39,57,702],[20,37,57,740],[21,36,57,756],[22,35,57,770],[23,34,57,782],[24,33,57,792],[25,32,57,800],[26,31,57,806],[27,30,57,810],[28,29,57,812],[2,56,58,112],[3,55,58,165],[4,54,58,216],[6,52,58,312],[7,51,58,357],[8,50,58,400],[9,49,58,441],[10,48,58,480],[12,46,58,552],[13,45,58,585],[14,44,58,616],[16,42,58,672],[18,40,58,720],[19,39,58,741],[20,38,58,760],[22,36,58,792],[24,34,58,816],[25,33,58,825],[26,32,58,832],[28,30,58,840],[2,57,59,114],[3,56,59,168],[4,55,59,220],[5,54,59,270],[7,52,59,364],[8,51,59,408],[9,50,59,450],[10,49,59,490],[11,48,59,528],[12,47,59,564],[13,46,59,598],[14,45,59,630],[15,44,59,660],[16,43,59,688],[17,42,59,714],[18,41,59,738],[19,40,59,760],[20,39,59,780],[21,38,59,798],[22,37,59,814],[23,36,59,828],[24,35,59,840],[25,34,59,850],[26,33,59,858],[27,32,59,864],[28,31,59,868],[29,30,59,870],[2,58,60,116],[3,57,60,171],[4,56,60,224],[5,55,60,275],[6,54,60,324],[8,52,60,416],[9,51,60,459],[10,50,60,500],[11,49,60,539],[12,48,60,576],[14,46,60,644],[15,45,60,675],[16,44,60,704],[18,42,60,756],[20,40,60,800],[21,39,60,819],[22,38,60,836],[24,36,60,864],[26,34,60,884],[27,33,60,891],[28,32,60,896],[3,58,61,174],[4,57,61,228],[5,56,61,280],[6,55,61,330],[7,54,61,378],[9,52,61,468],[10,51,61,510],[11,50,61,550],[12,49,61,588],[13,48,61,624],[15,46,61,690],[16,45,61,720],[17,44,61,748],[18,43,61,774],[19,42,61,798],[20,41,61,820],[21,40,61,840],[22,39,61,858],[23,38,61,874],[24,37,61,888],[25,36,61,900],[26,35,61,910],[27,34,61,918],[28,33,61,924],[29,32,61,928],[30,31,61,930],[2,60,62,120],[4,58,62,232],[5,57,62,285],[6,56,62,336],[7,55,62,385],[8,54,62,432],[10,52,62,520],[11,51,62,561],[12,50,62,600],[13,49,62,637],[14,48,62,672],[16,46,62,736],[17,45,62,765],[18,44,62,792],[20,42,62,840],[22,40,62,880],[23,39,62,897],[24,38,62,912],[26,36,62,936],[27,35,62,945],[28,34,62,952],[29,33,62,957],[30,32,62,960],[3,60,63,180],[5,58,63,290],[6,57,63,342],[7,56,63,392],[8,55,63,440],[9,54,63,486],[11,52,63,572],[12,51,63,612],[13,50,63,650],[15,48,63,720],[17,46,63,782],[18,45,63,810],[19,44,63,836],[20,43,63,860],[21,42,63,882],[22,41,63,902],[23,40,63,920],[24,39,63,936],[25,38,63,950],[26,37,63,962],[27,36,63,972],[28,35,63,980],[29,34,63,986],[30,33,63,990],[31,32,63,992],[2,62,64,124],[4,60,64,240],[6,58,64,348],[7,57,64,399],[8,56,64,448],[9,55,64,495],[10,54,64,540],[12,52,64,624],[13,51,64,663],[14,50,64,700],[15,49,64,735],[16,48,64,768],[18,46,64,828],[19,45,64,855],[20,44,64,880],[22,42,64,924],[24,40,64,960],[25,39,64,975],[26,38,64,988],[28,36,64,1008],[30,34,64,1020],[2,63,65,126],[3,62,65,186],[5,60,65,300],[7,58,65,406],[8,57,65,456],[9,56,65,504],[10,55,65,550],[11,54,65,594],[14,51,65,714],[15,50,65,750],[16,49,65,784],[17,48,65,816],[19,46,65,874],[20,45,65,900],[21,44,65,924],[22,43,65,946],[23,42,65,966],[24,41,65,984],[25,40,65,1000],[26,39,65,1014],[27,38,65,1026],[28,37,65,1036],[29,36,65,1044],[30,35,65,1050],[31,34,65,1054],[32,33,65,1056],[2,64,66,128],[3,63,66,189],[4,62,66,248],[6,60,66,360],[8,58,66,464],[9,57,66,513],[10,56,66,560],[12,54,66,648],[14,52,66,728],[15,51,66,765],[16,50,66,800],[18,48,66,864],[20,46,66,920],[21,45,66,945],[22,44,66,968],[24,42,66,1008],[26,40,66,1040],[27,39,66,1053],[28,38,66,1064],[30,36,66,1080],[32,34,66,1088],[2,65,67,130],[3,64,67,192],[4,63,67,252],[5,62,67,310],[7,60,67,420],[9,58,67,522],[10,57,67,570],[11,56,67,616],[12,55,67,660],[13,54,67,702],[15,52,67,780],[16,51,67,816],[17,50,67,850],[18,49,67,882],[19,48,67,912],[21,46,67,966],[22,45,67,990],[23,44,67,1012],[24,43,67,1032],[25,42,67,1050],[26,41,67,1066],[27,40,67,1080],[28,39,67,1092],[29,38,67,1102],[30,37,67,1110],[31,36,67,1116],[32,35,67,1120],[33,34,67,1122],[2,66,68,132],[3,65,68,195],[4,64,68,256],[5,63,68,315],[6,62,68,372],[8,60,68,480],[10,58,68,580],[11,57,68,627],[12,56,68,672],[13,55,68,715],[14,54,68,756],[16,52,68,832],[18,50,68,900],[20,48,68,960],[22,46,68,1012],[23,45,68,1035],[24,44,68,1056],[26,42,68,1092],[28,40,68,1120],[29,39,68,1131],[30,38,68,1140],[32,36,68,1152],[33,35,68,1155],[3,66,69,198],[4,65,69,260],[5,64,69,320],[6,63,69,378],[7,62,69,434],[9,60,69,540],[11,58,69,638],[12,57,69,684],[13,56,69,728],[14,55,69,770],[15,54,69,810],[17,52,69,884],[18,51,69,918],[19,50,69,950],[20,49,69,980],[21,48,69,1008],[24,45,69,1080],[25,44,69,1100],[26,43,69,1118],[27,42,69,1134],[28,41,69,1148],[29,40,69,1160],[30,39,69,1170],[31,38,69,1178],[32,37,69,1184],[33,36,69,1188],[34,35,69,1190],[2,68,70,136],[4,66,70,264],[5,65,70,325],[6,64,70,384],[7,63,70,441],[8,62,70,496],[10,60,70,600],[12,58,70,696],[13,57,70,741],[14,56,70,784],[15,55,70,825],[16,54,70,864],[18,52,70,936],[19,51,70,969],[20,50,70,1000],[22,48,70,1056],[24,46,70,1104],[25,45,70,1125],[26,44,70,1144],[28,42,70,1176],[30,40,70,1200],[32,38,70,1216],[34,36,70,1224],[2,69,71,138],[3,68,71,204],[5,66,71,330],[6,65,71,390],[7,64,71,448],[8,63,71,504],[9,62,71,558],[11,60,71,660],[13,58,71,754],[14,57,71,798],[15,56,71,840],[16,55,71,880],[17,54,71,918],[19,52,71,988],[20,51,71,1020],[21,50,71,1050],[22,49,71,1078],[23,48,71,1104],[25,46,71,1150],[26,45,71,1170],[27,44,71,1188],[28,43,71,1204],[29,42,71,1218],[30,41,71,1230],[31,40,71,1240],[32,39,71,1248],[33,38,71,1254],[34,37,71,1258],[35,36,71,1260],[2,70,72,140],[3,69,72,207],[4,68,72,272],[6,66,72,396],[7,65,72,455],[8,64,72,512],[9,63,72,567],[10,62,72,620],[12,60,72,720],[14,58,72,812],[15,57,72,855],[16,56,72,896],[17,55,72,935],[18,54,72,972],[20,52,72,1040],[21,51,72,1071],[22,50,72,1100],[24,48,72,1152],[26,46,72,1196],[27,45,72,1215],[28,44,72,1232],[30,42,72,1260],[32,40,72,1280],[34,38,72,1292],[3,70,73,210],[4,69,73,276],[5,68,73,340],[7,66,73,462],[8,65,73,520],[9,64,73,576],[10,63,73,630],[11,62,73,682],[13,60,73,780],[15,58,73,870],[16,57,73,912],[17,56,73,952],[18,55,73,990],[19,54,73,1026],[21,52,73,1092],[22,51,73,1122],[23,50,73,1150],[24,49,73,1176],[25,48,73,1200],[27,46,73,1242],[28,45,73,1260],[29,44,73,1276],[31,42,73,1302],[32,41,73,1312],[33,40,73,1320],[34,39,73,1326],[35,38,73,1330],[36,37,73,1332],[2,72,74,144],[4,70,74,280],[5,69,74,345],[6,68,74,408],[8,66,74,528],[9,65,74,585],[10,64,74,640],[11,63,74,693],[12,62,74,744],[14,60,74,840],[16,58,74,928],[17,57,74,969],[18,56,74,1008],[20,54,74,1080],[22,52,74,1144],[23,51,74,1173],[24,50,74,1200],[26,48,74,1248],[28,46,74,1288],[30,44,74,1320],[32,42,74,1344],[34,40,74,1360],[35,39,74,1365],[36,38,74,1368],[3,72,75,216],[5,70,75,350],[6,69,75,414],[7,68,75,476],[9,66,75,594],[10,65,75,650],[11,64,75,704],[12,63,75,756],[13,62,75,806],[15,60,75,900],[17,58,75,986],[18,57,75,1026],[19,56,75,1064],[20,55,75,1100],[21,54,75,1134],[23,52,75,1196],[24,51,75,1224],[27,48,75,1296],[29,46,75,1334],[30,45,75,1350],[31,44,75,1364],[33,42,75,1386],[34,41,75,1394],[35,40,75,1400],[36,39,75,1404],[37,38,75,1406],[2,74,76,148],[4,72,76,288],[6,70,76,420],[7,69,76,483],[8,68,76,544],[10,66,76,660],[11,65,76,715],[12,64,76,768],[13,63,76,819],[14,62,76,868],[16,60,76,960],[18,58,76,1044],[20,56,76,1120],[21,55,76,1155],[22,54,76,1188],[24,52,76,1248],[25,51,76,1275],[26,50,76,1300],[27,49,76,1323],[28,48,76,1344],[30,46,76,1380],[32,44,76,1408],[34,42,76,1428],[36,40,76,1440],[2,75,77,150],[3,74,77,222],[5,72,77,360],[7,70,77,490],[8,69,77,552],[9,68,77,612],[11,66,77,726],[12,65,77,780],[13,64,77,832],[14,63,77,882],[15,62,77,930],[17,60,77,1020],[19,58,77,1102],[20,57,77,1140],[21,56,77,1176],[23,54,77,1242],[25,52,77,1300],[26,51,77,1326],[27,50,77,1350],[29,48,77,1392],[31,46,77,1426],[32,45,77,1440],[33,44,77,1452],[35,42,77,1470],[36,41,77,1476],[37,40,77,1480],[38,39,77,1482],[2,76,78,152],[3,75,78,225],[4,74,78,296],[6,72,78,432],[8,70,78,560],[9,69,78,621],[10,68,78,680],[12,66,78,792],[14,64,78,896],[15,63,78,945],[16,62,78,992],[18,60,78,1080],[20,58,78,1160],[21,57,78,1197],[22,56,78,1232],[24,54,78,1296],[27,51,78,1377],[28,50,78,1400],[30,48,78,1440],[32,46,78,1472],[33,45,78,1485],[34,44,78,1496],[36,42,78,1512],[38,40,78,1520],[2,77,79,154],[3,76,79,228],[4,75,79,300],[5,74,79,370],[7,72,79,504],[9,70,79,630],[10,69,79,690],[11,68,79,748],[13,66,79,858],[14,65,79,910],[15,64,79,960],[16,63,79,1008],[17,62,79,1054],[19,60,79,1140],[21,58,79,1218],[22,57,79,1254],[23,56,79,1288],[24,55,79,1320],[25,54,79,1350],[27,52,79,1404],[28,51,79,1428],[29,50,79,1450],[30,49,79,1470],[31,48,79,1488],[33,46,79,1518],[34,45,79,1530],[35,44,79,1540],[37,42,79,1554],[39,40,79,1560],[2,78,80,156],[3,77,80,231],[4,76,80,304],[5,75,80,375],[6,74,80,444],[8,72,80,576],[10,70,80,700],[11,69,80,759],[12,68,80,816],[14,66,80,924],[15,65,80,975],[17,63,80,1071],[18,62,80,1116],[20,60,80,1200],[22,58,80,1276],[23,57,80,1311],[24,56,80,1344],[26,54,80,1404],[28,52,80,1456],[30,50,80,1500],[32,48,80,1536],[34,46,80,1564],[35,45,80,1575],[36,44,80,1584],[38,42,80,1596],[3,78,81,234],[4,77,81,308],[5,76,81,380],[6,75,81,450],[7,74,81,518],[9,72,81,648],[11,70,81,770],[12,69,81,828],[13,68,81,884],[15,66,81,990],[16,65,81,1040],[17,64,81,1088],[18,63,81,1134],[19,62,81,1178],[21,60,81,1260],[23,58,81,1334],[24,57,81,1368],[25,56,81,1400],[26,55,81,1430],[27,54,81,1458],[29,52,81,1508],[30,51,81,1530],[31,50,81,1550],[32,49,81,1568],[33,48,81,1584],[35,46,81,1610],[36,45,81,1620],[37,44,81,1628],[39,42,81,1638],[2,80,82,160],[4,78,82,312],[5,77,82,385],[6,76,82,456],[7,75,82,525],[8,74,82,592],[10,72,82,720],[12,70,82,840],[13,69,82,897],[14,68,82,952],[16,66,82,1056],[17,65,82,1105],[18,64,82,1152],[19,63,82,1197],[20,62,82,1240],[22,60,82,1320],[24,58,82,1392],[25,57,82,1425],[26,56,82,1456],[27,55,82,1485],[28,54,82,1512],[30,52,82,1560],[32,50,82,1600],[33,49,82,1617],[34,48,82,1632],[36,46,82,1656],[38,44,82,1672],[40,42,82,1680],[2,81,83,162],[3,80,83,240],[5,78,83,390],[6,77,83,462],[7,76,83,532],[8,75,83,600],[9,74,83,666],[11,72,83,792],[13,70,83,910],[14,69,83,966],[15,68,83,1020],[17,66,83,1122],[18,65,83,1170],[19,64,83,1216],[20,63,83,1260],[21,62,83,1302],[23,60,83,1380],[25,58,83,1450],[26,57,83,1482],[27,56,83,1512],[28,55,83,1540],[29,54,83,1566],[31,52,83,1612],[32,51,83,1632],[33,50,83,1650],[35,48,83,1680],[37,46,83,1702],[38,45,83,1710],[39,44,83,1716],[2,82,84,164],[3,81,84,243],[4,80,84,320],[6,78,84,468],[7,77,84,539],[8,76,84,608],[9,75,84,675],[10,74,84,740],[12,72,84,864],[14,70,84,980],[15,69,84,1035],[16,68,84,1088],[18,66,84,1188],[20,64,84,1280],[21,63,84,1323],[22,62,84,1364],[24,60,84,1440],[26,58,84,1508],[27,57,84,1539],[28,56,84,1568],[30,54,84,1620],[32,52,84,1664],[34,50,84,1700],[36,48,84,1728],[38,46,84,1748],[39,45,84,1755],[40,44,84,1760],[3,82,85,246],[4,81,85,324],[5,80,85,400],[7,78,85,546],[8,77,85,616],[9,76,85,684],[10,75,85,750],[11,74,85,814],[13,72,85,936],[15,70,85,1050],[16,69,85,1104],[19,66,85,1254],[20,65,85,1300],[21,64,85,1344],[22,63,85,1386],[23,62,85,1426],[25,60,85,1500],[27,58,85,1566],[28,57,85,1596],[29,56,85,1624],[30,55,85,1650],[31,54,85,1674],[33,52,85,1716],[35,50,85,1750],[36,49,85,1764],[37,48,85,1776],[39,46,85,1794],[40,45,85,1800],[2,84,86,168],[4,82,86,328],[5,81,86,405],[6,80,86,480],[8,78,86,624],[9,77,86,693],[10,76,86,760],[11,75,86,825],[12,74,86,888],[14,72,86,1008],[16,70,86,1120],[17,69,86,1173],[18,68,86,1224],[20,66,86,1320],[21,65,86,1365],[22,64,86,1408],[23,63,86,1449],[24,62,86,1488],[26,60,86,1560],[28,58,86,1624],[30,56,86,1680],[32,54,86,1728],[34,52,86,1768],[36,50,86,1800],[38,48,86,1824],[42,44,86,1848],[2,85,87,170],[3,84,87,252],[5,82,87,410],[6,81,87,486],[7,80,87,560],[9,78,87,702],[10,77,87,770],[11,76,87,836],[12,75,87,900],[13,74,87,962],[15,72,87,1080],[17,70,87,1190],[18,69,87,1242],[19,68,87,1292],[21,66,87,1386],[22,65,87,1430],[23,64,87,1472],[24,63,87,1512],[25,62,87,1550],[27,60,87,1620],[30,57,87,1710],[31,56,87,1736],[32,55,87,1760],[33,54,87,1782],[35,52,87,1820],[36,51,87,1836],[37,50,87,1850],[39,48,87,1872],[42,45,87,1890],[2,86,88,172],[3,85,88,255],[4,84,88,336],[6,82,88,492],[7,81,88,567],[8,80,88,640],[10,78,88,780],[12,76,88,912],[13,75,88,975],[14,74,88,1036],[16,72,88,1152],[18,70,88,1260],[19,69,88,1311],[20,68,88,1360],[22,66,88,1452],[24,64,88,1536],[25,63,88,1575],[26,62,88,1612],[28,60,88,1680],[30,58,88,1740],[32,56,88,1792],[34,54,88,1836],[36,52,88,1872],[40,48,88,1920],[42,46,88,1932],[2,87,89,174],[3,86,89,258],[4,85,89,340],[5,84,89,420],[7,82,89,574],[8,81,89,648],[9,80,89,720],[11,78,89,858],[12,77,89,924],[13,76,89,988],[14,75,89,1050],[15,74,89,1110],[17,72,89,1224],[19,70,89,1330],[20,69,89,1380],[21,68,89,1428],[23,66,89,1518],[24,65,89,1560],[25,64,89,1600],[26,63,89,1638],[27,62,89,1674],[29,60,89,1740],[31,58,89,1798],[32,57,89,1824],[33,56,89,1848],[35,54,89,1890],[37,52,89,1924],[38,51,89,1938],[39,50,89,1950],[40,49,89,1960],[44,45,89,1980],[2,88,90,176],[3,87,90,261],[4,86,90,344],[5,85,90,425],[6,84,90,504],[8,82,90,656],[10,80,90,800],[12,78,90,936],[14,76,90,1064],[15,75,90,1125],[16,74,90,1184],[18,72,90,1296],[20,70,90,1400],[21,69,90,1449],[22,68,90,1496],[24,66,90,1584],[26,64,90,1664],[28,62,90,1736],[30,60,90,1800],[32,58,90,1856],[34,56,90,1904],[36,54,90,1944],[42,48,90,2016],[3,88,91,264],[4,87,91,348],[5,86,91,430],[6,85,91,510],[7,84,91,588],[9,82,91,738],[10,81,91,810],[11,80,91,880],[13,78,91,1014],[14,77,91,1078],[15,76,91,1140],[16,75,91,1200],[17,74,91,1258],[19,72,91,1368],[21,70,91,1470],[22,69,91,1518],[23,68,91,1564],[25,66,91,1650],[27,64,91,1728],[28,63,91,1764],[29,62,91,1798],[31,60,91,1860],[33,58,91,1914],[34,57,91,1938],[35,56,91,1960],[36,55,91,1980],[40,51,91,2040],[45,46,91,2070],[2,90,92,180],[4,88,92,352],[5,87,92,435],[6,86,92,516],[7,85,92,595],[8,84,92,672],[10,82,92,820],[11,81,92,891],[12,80,92,960],[14,78,92,1092],[15,77,92,1155],[16,76,92,1216],[17,75,92,1275],[18,74,92,1332],[20,72,92,1440],[22,70,92,1540],[24,68,92,1632],[26,66,92,1716],[27,65,92,1755],[28,64,92,1792],[30,62,92,1860],[32,60,92,1920],[34,58,92,1972],[36,56,92,2016],[38,54,92,2052],[40,52,92,2080],[42,50,92,2100],[44,48,92,2112],[2,91,93,182],[3,90,93,270],[5,88,93,440],[6,87,93,522],[7,86,93,602],[8,85,93,680],[9,84,93,756],[11,82,93,902],[12,81,93,972],[13,80,93,1040],[15,78,93,1170],[16,77,93,1232],[17,76,93,1292],[18,75,93,1350],[19,74,93,1406],[21,72,93,1512],[23,70,93,1610],[24,69,93,1656],[25,68,93,1700],[27,66,93,1782],[28,65,93,1820],[29,64,93,1856],[30,63,93,1890],[33,60,93,1980],[35,58,93,2030],[36,57,93,2052],[42,51,93,2142],[45,48,93,2160],[2,92,94,184],[3,91,94,273],[4,90,94,360],[6,88,94,528],[7,87,94,609],[8,86,94,688],[9,85,94,765],[10,84,94,840],[12,82,94,984],[13,81,94,1053],[14,80,94,1120],[16,78,94,1248],[18,76,94,1368],[19,75,94,1425],[20,74,94,1480],[22,72,94,1584],[24,70,94,1680],[25,69,94,1725],[26,68,94,1768],[28,66,94,1848],[30,64,94,1920],[32,62,94,1984],[34,60,94,2040],[39,55,94,2145],[40,54,94,2160],[42,52,94,2184],[44,50,94,2200],[45,49,94,2205],[2,93,95,186],[3,92,95,276],[4,91,95,364],[5,90,95,450],[7,88,95,616],[8,87,95,696],[9,86,95,774],[10,85,95,850],[11,84,95,924],[13,82,95,1066],[14,81,95,1134],[15,80,95,1200],[17,78,95,1326],[18,77,95,1386],[20,75,95,1500],[21,74,95,1554],[23,72,95,1656],[25,70,95,1750],[26,69,95,1794],[27,68,95,1836],[29,66,95,1914],[30,65,95,1950],[31,64,95,1984],[32,63,95,2016],[33,62,95,2046],[35,60,95,2100],[39,56,95,2184],[40,55,95,2200],[44,51,95,2244],[2,94,96,188],[3,93,96,279],[4,92,96,368],[5,91,96,455],[6,90,96,540],[8,88,96,704],[9,87,96,783],[10,86,96,860],[11,85,96,935],[12,84,96,1008],[14,82,96,1148],[15,81,96,1215],[16,80,96,1280],[18,78,96,1404],[20,76,96,1520],[21,75,96,1575],[22,74,96,1628],[24,72,96,1728],[26,70,96,1820],[28,68,96,1904],[30,66,96,1980],[34,62,96,2108],[36,60,96,2160],[40,56,96,2240],[42,54,96,2268],[2,95,97,190],[3,94,97,282],[4,93,97,372],[5,92,97,460],[6,91,97,546],[7,90,97,630],[9,88,97,792],[10,87,97,870],[11,86,97,946],[12,85,97,1020],[13,84,97,1092],[15,82,97,1230],[16,81,97,1296],[17,80,97,1360],[19,78,97,1482],[20,77,97,1540],[21,76,97,1596],[22,75,97,1650],[23,74,97,1702],[25,72,97,1800],[27,70,97,1890],[28,69,97,1932],[29,68,97,1972],[31,66,97,2046],[32,65,97,2080],[33,64,97,2112],[34,63,97,2142],[40,57,97,2280],[45,52,97,2340],[48,49,97,2352],[2,96,98,192],[3,95,98,285],[4,94,98,376],[5,93,98,465],[6,92,98,552],[7,91,98,637],[8,90,98,720],[10,88,98,880],[11,87,98,957],[12,86,98,1032],[13,85,98,1105],[14,84,98,1176],[16,82,98,1312],[17,81,98,1377],[18,80,98,1440],[20,78,98,1560],[21,77,98,1617],[22,76,98,1672],[23,75,98,1725],[24,74,98,1776],[26,72,98,1872],[28,70,98,1960],[30,68,98,2040],[32,66,98,2112],[33,65,98,2145],[34,64,98,2176],[35,63,98,2205],[38,60,98,2280],[42,56,98,2352],[48,50,98,2400],[3,96,99,288],[4,95,99,380],[5,94,99,470],[6,93,99,558],[7,92,99,644],[8,91,99,728],[9,90,99,810],[11,88,99,968],[12,87,99,1044],[13,86,99,1118],[14,85,99,1190],[15,84,99,1260],[17,82,99,1394],[18,81,99,1458],[19,80,99,1520],[21,78,99,1638],[23,76,99,1748],[24,75,99,1800],[25,74,99,1850],[27,72,99,1944],[29,70,99,2030],[30,69,99,2070],[31,68,99,2108],[35,64,99,2240],[36,63,99,2268],[39,60,99,2340],[2,98,100,196],[4,96,100,384],[5,95,100,475],[6,94,100,564],[7,93,100,651],[8,92,100,736],[9,91,100,819],[10,90,100,900],[12,88,100,1056],[13,87,100,1131],[14,86,100,1204],[15,85,100,1275],[16,84,100,1344],[18,82,100,1476],[19,81,100,1539],[20,80,100,1600],[22,78,100,1716],[24,76,100,1824],[26,74,100,1924],[28,72,100,2016],[30,70,100,2100],[32,68,100,2176],[34,66,100,2244],[40,60,100,2400]].
?- time(s2(Q,100)).
% 11,163,637 inferences, 1.702 CPU in 1.740 seconds (98% CPU, 6558890 Lips)
Q = [[2,9,11,18],[3,8,11,24],[4,7,11,28],[2,15,17,30],[5,6,11,30],[3,14,17,42],[2,21,23,42],[2,25,27,50],[4,13,17,52],[2,27,29,54],[3,20,23,60],[5,12,17,60],[6,11,17,66],[2,33,35,66],[2,35,37,70],[7,10,17,70],[8,9,17,72],[3,24,27,72],[4,19,23,76],[3,26,29,78],[2,39,41,78],[2,45,47,90],[5,18,23,90],[4,23,27,92],[3,32,35,96],[4,25,29,100],[2,51,53,102],[6,17,23,102],[3,34,37,102],[5,22,27,110],[7,16,23,112],[3,38,41,114],[5,24,29,120],[8,15,23,120],[4,31,35,124],[9,14,23,126],[6,21,27,126],[10,13,23,130],[4,33,37,132],[11,12,23,132],[3,44,47,132],[6,23,29,138],[7,20,27,140],[4,37,41,148],[5,30,35,150],[3,50,53,150],[8,19,27,152],[7,22,29,154],[5,32,37,160],[9,18,27,162],[8,21,29,168],[10,17,27,170],[4,43,47,172],[6,29,35,174],[11,16,27,176],[9,20,29,180],[5,36,41,180],[12,15,27,180],[13,14,27,182],[6,31,37,186],[10,19,29,190],[4,49,53,196],[7,28,35,196],[11,18,29,198],[12,17,29,204],[13,16,29,208],[5,42,47,210],[14,15,29,210],[7,30,37,210],[6,35,41,210],[8,27,35,216],[8,29,37,232],[9,26,35,234],[7,34,41,238],[5,48,53,240],[6,41,47,246],[10,25,35,250],[9,28,37,252],[8,33,41,264],[11,24,35,264],[10,27,37,270],[12,23,35,276],[7,40,47,280],[6,47,53,282],[13,22,35,286],[11,26,37,286],[9,32,41,288],[14,21,35,294],[12,25,37,300],[15,20,35,300],[16,19,35,304],[17,18,35,306],[10,31,41,310],[8,39,47,312],[13,24,37,312],[14,23,37,322],[7,46,53,322],[11,30,41,330],[15,22,37,330],[16,21,37,336],[17,20,37,340],[18,19,37,342],[9,38,47,342],[12,29,41,348],[8,45,53,360],[13,28,41,364],[10,37,47,370],[14,27,41,378],[15,26,41,390],[11,36,47,396],[9,44,53,396],[16,25,41,400],[17,24,41,408],[18,23,41,414],[19,22,41,418],[12,35,47,420],[20,21,41,420],[10,43,53,430],[13,34,47,442],[14,33,47,462],[11,42,53,462],[15,32,47,480],[12,41,53,492],[16,31,47,496],[17,30,47,510],[13,40,53,520],[18,29,47,522],[19,28,47,532],[20,27,47,540],[14,39,53,546],[21,26,47,546],[22,25,47,550],[23,24,47,552],[15,38,53,570],[16,37,53,592],[17,36,53,612],[18,35,53,630],[19,34,53,646],[20,33,53,660],[21,32,53,672],[22,31,53,682],[23,30,53,690],[24,29,53,696],[25,28,53,700],[26,27,53,702]].
?- time(s3(Q,100)).
% 11,204,219 inferences, 1.723 CPU in 1.754 seconds (98% CPU, 6502267 Lips)
Q = [[2,9,11,18],[4,7,11,28],[3,8,11,24],[4,13,17,52],[4,19,23,76],[10,13,23,130],[7,16,23,112],[7,20,27,140],[8,19,27,152],[5,22,27,110],[11,16,27,176],[9,18,27,162],[2,25,27,50],[13,14,27,182],[4,23,27,92],[10,17,27,170],[13,16,29,208],[8,21,29,168],[11,18,29,198],[4,25,29,100],[2,27,29,54],[10,19,29,190],[7,22,29,154],[6,23,29,138],[12,17,29,204],[17,18,35,306],[3,32,35,96],[12,23,35,276],[14,21,35,294],[8,27,35,216],[6,29,35,174],[4,31,35,124],[9,26,35,234],[10,25,35,250],[16,19,35,304],[9,28,37,252],[5,32,37,160],[6,31,37,186],[8,29,37,232],[16,21,37,336],[10,27,37,270],[17,20,37,340],[14,27,41,378],[7,34,41,238],[12,29,41,348],[3,38,41,114],[18,23,41,414],[16,25,41,400],[13,28,41,364],[4,37,41,148],[10,31,41,310],[15,26,41,390],[9,32,41,288],[19,22,41,418],[17,24,41,408],[15,32,47,480],[22,25,47,550],[4,43,47,172],[16,31,47,496],[19,28,47,532],[6,41,47,246],[23,24,47,552],[18,29,47,522],[17,30,47,510],[7,40,47,280],[20,27,47,540],[10,37,47,370],[13,34,47,442],[21,32,53,672],[13,40,53,520],[25,28,53,700],[17,36,53,612],[6,47,53,282],[23,30,53,690],[15,38,53,570],[19,34,53,646],[10,43,53,430],[12,41,53,492],[22,31,53,682],[5,48,53,240],[26,27,53,702],[8,45,53,360],[18,35,53,630],[24,29,53,696],[16,37,53,592],[20,33,53,660]].
?- time(s4(Q,100)).
% 11,220,296 inferences, 1.676 CPU in 1.709 seconds (98% CPU, 6693793 Lips)
Q = [[4,13,17,52]].
*/