HandDiff
Mark up your diff how YOU intended it to look.
Input Texts
Diff Result
DP Table
Branch Choices
Documentation
Left
-: must delete
Right +: must insert
Left =: must keep
Right =: must keep
DP recurrence with interventions
upAllowed(i) = (left line i is not marked "=")
leftAllowed(j) = (right line j is not marked "=")
diagAllowed(i,j) = (L[i-1] === R[j-1]) && (left line i is not marked "-") && (right line j is not marked "+")
dp[0][0] = 0
dp[i][j] = max(
upAllowed(i) ? dp[i-1][j] : -∞,
leftAllowed(j) ? dp[i][j-1] : -∞,
diagAllowed(i,j) ? dp[i-1][j-1] + 1 : -∞
)
How the buttons change transitions:
Left - blocks diagonal for that left line (must be deleted),
Right + blocks diagonal for that right line (must be inserted),
Left = blocks the upward move for that left line (cannot be deleted),
Right = blocks the left move for that right line (cannot be inserted).
If the final value is dp[n][m] = -∞, the constraints are inconsistent
and no valid diff path exists.