all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
function list = permutationSort(list)
|
||||
|
||||
permutations = perms(1:numel(list)); %Generate all permutations of the item indicies
|
||||
|
||||
%Test every permutation of the indicies of the original list
|
||||
for i = (1:size(permutations,1))
|
||||
if issorted( list(permutations(i,:)) )
|
||||
list = list(permutations(i,:));
|
||||
return %Once the correct permutation of the original list is found break out of the program
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
>> permutationSort([4 3 1 5 6 2])
|
||||
|
||||
ans =
|
||||
|
||||
1 2 3 4 5 6
|
||||
Loading…
Add table
Add a link
Reference in a new issue