name = 'slowest_sort_ever/2' slug = 'sort a list by randomly permuting elements' description = '''\

slowest_sort_ever(L, SL): the list SL contains the elements of L sorted in non-decreasing order. Average and worst case running time is O(n * n!).

?- slowest_sort_ever([2,3,1,5,4], L).
  L = [1,2,3,4,5].
''' plan = ['''\

This exercise is mostly for fun... all you need are two lines, i.e. two prolog goals.

''', '''\

Perhaps you can reuse some previous solutions?

''', '''\

Which of the previous solutions has time complexity of O(n!)? Use it!

'''] hint = { 'eq_instead_of_equ': '''\

The operator == is "stricter" than operator = in the sense that for the latter it is enough to be able to make the two operands equal (unification).

Of course, you can also solve the exercise without explicit use of either of these two operators, just remember that unification is implicitly performed with the predicate's arguments (head of clause).

''', 'eq_instead_of_equ_markup': '''\

Perhaps the operator for unification (=) would be better?

''', 'predicate_always_false': '''\

It seems your predicate is always "false". Did you give it the correct name, or is it perhaps misspelled?

If the name is correct, check whether something else is misspelled, perhaps there is a full stop instead of a comma or vice versa, or maybe you typed a variable name in lowercase?

It is, of course, also possible that your conditions are too restrictive, or even impossible to satisfy (as would be, for example, the condition that X is simultaneously smaller and greater than Y, or something similarly impossible).

''', 'timeout': '''\

Is there an infinite recursion at work here? How will it ever stop?

Or perhaps is there a missing, faulty, or simply incompatible (with the general recursive case) base case?

''', 'no_permute': '''\

Hmmm, which of the previous exercises has time complexity of O(n!)? How can you use it here?

''', 'no_isSorted': '''\

You're on the right path, just a bit more to go. Perhaps you can reuse another previous exercise?

''', }