Implement the patience diff algorithm