Shortest common supersequence: Difference between revisions

m (add an URL link.)
Line 186:
SCS(abcbdab, bdcaba) = abdcabdab
</pre>
 
=={{header|Julia}}==
{{trans|D}}
<lang Julia>using Memoize
 
@memoize function scs(x, y)
if x == ""
return y
elseif y == ""
return x
elseif x[1] == y[1]
return "$(x[1])$(scs(x[2:end], y[2:end]))"
elseif length(scs(x, y[2:end])) <= length(scs(x[2:end], y))
return "$(y[1])$(scs(x, y[2:end]))"
else
return "$(x[1])$(scs(x[2:end], y))"
end
end
 
println(scs("abcbdab", "bdcaba"))
</lang>
{{out}}
<pre>
abdcabdab
</pre>
 
 
=={{header|Kotlin}}==
4,102

edits