Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,30 @@
def heapSort( a ) =
heapify( a )
end = a.length() - 1
while end > 0
a(end), a(0) = a(0), a(end)
siftDown( a, 0, --end )
def heapify( a ) =
for i <- (a.length() - 2)\2..0 by -1
siftDown( a, i, a.length() - 1 )
def siftDown( a, start, end ) =
root = start
while root*2 + 1 <= end
child = root*2 + 1
if child + 1 <= end and a(child) < a(child + 1)
child++
if a(root) < a(child)
a(root), a(child) = a(child), a(root)
root = child
else
break
a = array( [7, 2, 6, 1, 9, 5, 0, 3, 8, 4] )
heapSort( a )
println( a )