Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,30 @@
import "/sort" for Find
class Pancake {
construct new(a) {
_a = a.toList
}
flip(r) {
for (l in 0...r) {
_a.swap(r, l)
r = r - 1
}
}
sort() {
for (uns in _a.count-1..1) {
var h = Find.highest(_a[0..uns])
var lx = h[2][0]
flip(lx)
flip(uns)
}
}
toString { _a.toString }
}
var p = Pancake.new([31, 41, 59, 26, 53, 58, 97, 93, 23, 84])
System.print("unsorted: %(p)")
p.sort()
System.print("sorted : %(p)")