| func levenshtein(s string, t string) int { |
| dists := make([][]int, len(s)+1) |
| dists[i] = make([]int, len(t)+1) |
| dists[i+1][j+1] = dists[i][j] |
| dists[i+1][j+1] = dists[i][j] + 1 |
| if dists[i+1][j] < dists[i+1][j+1] { |
| dists[i+1][j+1] = dists[i+1][j] + 1 |
| if dists[i][j+1] < dists[i+1][j+1] { |
| dists[i+1][j+1] = dists[i][j+1] + 1 |
| return dists[len(s)][len(t)] |
| func closestChoice(cmd string, choices []string) (string, int) { |
| for i, c := range choices { |
| if mincmd < 0 || l < mindist { |
| return choices[mincmd], mindist |