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,26 @@
class Array {
method radix_sort(base=10) {
var arr = self.clone;
var rounds = ([arr.minmax].map{.abs}.max -> log(base).floor + 1);
for i in ^rounds {
var buckets = (2*base -> of {[]});
var base_i = base**i;
for n in arr {
var digit = (n/base_i % base);
digit += base if (0 <= n);
buckets[digit].append(n);
}
arr = buckets.flatten;
}
return arr;
}
}
for arr in [
[1, 3, 8, 9, 0, 0, 8, 7, 1, 6],
[170, 45, 75, 90, 2, 24, 802, 66],
[170, 45, 75, 90, 2, 24, -802, -66],
[100000, -10000, 400, 23, 10000],
] {
say arr.radix_sort;
}