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,20 @@
def gnomeSort(array) {
var size := array.size()
var i := 1
var j := 2
while (i < size) {
if (array[i-1] <= array[i]) {
i := j
j += 1
} else {
def t := array[i-1]
array[i-1] := array[i]
array[i] := t
i -= 1
if (i <=> 0) {
i := j
j += 1
}
}
}
}

View file

@ -0,0 +1,6 @@
? def a := [7,9,4,2,1,3,6,5,0,8].diverge()
# value: [7, 9, 4, 2, 1, 3, 6, 5, 0, 8].diverge()
? gnomeSort(a)
? a
# value: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].diverge()