summaryrefslogtreecommitdiff
path: root/prolog/problems/sorting/slowest_sort_ever_2/common.py
blob: fc8f9801bda3e4b40b7386b5e5b91d0c8761ba94 (plain)
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
# coding=utf-8

id = 126
number = 33
visible = True
facts = None

solution = '''\
del126(X, [X|T], T).
del126(X, [Y|T], [Y|L]) :-
  del126(X, T, L).

permute126([], []).
permute126(L, [X|P]) :-
  del126(X, L, L1),
  permute126(L1, P).

is_sorted126([_]).
is_sorted126([H1,H2|T]) :-
  H1 =< H2,
  is_sorted126([H2|T]).

slowest_sort_ever(L, S) :-
  permute126(L, S),
  is_sorted126(S).
'''