myers-diff
myers-diff copied to clipboard
printTrace
thanks your implementation helped me to understand the algorithm。
https://github.com/cj1128/myers-diff/blob/9678f9a574722a02f10b91329bb8793b64475b67/main.go#L200
not all k in [-d, d] will save in trace. if k not in trace x := v[k]
x will be zero as default.
may be this is the better
func printTrace(trace []map[int]int) {
for d := 0; d < len(trace); d++ {
fmt.Printf("d = %d:\n", d)
v := trace[d]
for k, x := range v {
y := x - k
fmt.Printf(" k = %2d: (%d, %d)\n", k, x, y)
}
}
}