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,24 @@
# The "while" loops are implemented using the following jq function:
# As soon as "condition" is true, then emit . and stop:
def do_until(condition; next):
def u: if condition then . else (next|u) end;
u;
# sort the input array
def shellSort:
length as $length
| [ ($length/2|floor), .] # L1: state: [h, array]
| do_until( .[0] == 0;
.[0] as $h
| reduce range($h; $length) as $i # L2: state: array
( .[1];
.[$i] as $k
| [ $i, . ] # L3: state: [j, array]
| do_until( .[0] < $h or ($k >= .[1][.[0] - $h]);
.[0] as $j
| [ ($j - $h), (.[1]|setpath([$j]; .[$j - $h])) ] )
| .[0] as $j | (.[1]|setpath([$j]; $k)) # i.e. a[j] = $k
)
| [(($h+1)*5/11 | floor), .] )
| .[1] ;

View file

@ -0,0 +1,3 @@
([],
[5,null,3,1,2,0,4.4,5]
) | shellSort

View file

@ -0,0 +1,3 @@
$ jq -M -c -n -f Shell_sort.jq
[]
[null,0,1,2,3,4.4,5,5]