Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
import std.stdio, std.functional, std.array, std.range;
|
||||
|
||||
dstring scs(in dstring x, in dstring y) nothrow @safe {
|
||||
alias mScs = memoize!scs;
|
||||
if (x.empty) return y;
|
||||
if (y.empty) return x;
|
||||
if (x.front == y.front)
|
||||
return x.front ~ mScs(x.dropOne, y.dropOne);
|
||||
if (mScs(x, y.dropOne).length <= mScs(x.dropOne, y).length)
|
||||
return y.front ~ mScs(x, y.dropOne);
|
||||
else
|
||||
return x.front ~ mScs(x.dropOne, y);
|
||||
}
|
||||
|
||||
void main() @safe {
|
||||
scs("abcbdab", "bdcaba").writeln;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue