Working EditDistance using dynamic programming