Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue