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,15 @@
func lev(s, t) is cached {
s.is_empty && return t.len;
t.is_empty && return s.len;
var s1 = s.ft(1);
var t1 = t.ft(1);
s[0] == t[0] ? __FUNC__(s1, t1)
: 1+[
__FUNC__(s1, t1),
__FUNC__(s, t1),
__FUNC__(s1, t )
].min;
}

View file

@ -0,0 +1,11 @@
func lev(s, t) {
var d = [@(0 .. t.len), s.len.of {[_]}...]
for i,j in (^s ~X ^t) {
d[i+1][j+1] = (
s[i] == t[j]
? d[i][j]
: 1+Math.min(d[i][j+1], d[i+1][j], d[i][j])
)
}
d[-1][-1]
}

View file

@ -0,0 +1,2 @@
say lev(%c'kitten', %c'sitting'); # prints: 3
say lev(%c'rosettacode', %c'raisethysword'); # prints: 8