all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,31 @@
bundle Default {
class Stooge {
function : Main(args : String[]) ~ Nil {
nums := [1, 4, 5, 3, -6, 3, 7, 10, -2, -5];
StoogeSort(nums);
each(i : nums) {
IO.Console->Print(nums[i])->Print(",");
};
IO.Console->PrintLine();
}
function : native : StoogeSort(l : Int[]) ~ Nil {
StoogeSort(l, 0, l->Size() - 1);
}
function : native : StoogeSort(l : Int[], i : Int, j : Int) ~ Nil {
if(l[j] < l[i]) {
tmp := l[i];
l[i] := l[j];
l[j] := tmp;
};
if(j - i > 1) {
t := (j - i + 1) / 3;
StoogeSort(l, i, j - t);
StoogeSort(l, i + t, j);
StoogeSort(l, i, j - t);
};
}
}
}