title: How to use deltas on 3 sentences in Ruby?
body: <p>Suppose I have the following sentences:</p>
  
  <pre><code>s1 = "The red dog jumped over the hill, followed by the crazy clown."
  s2 = "The green fox jumped over the hill, followed by the crazy clown."
  s3 = "The red dog jumped over the hill, followed by the dumb dolphin."
  </code></pre>
  
  <p>I want to be able to store the deltas of s2-s1 and s3-s1 in some compressed form, like: s2_d_s1 = -"red dog" +"green fox"</p>
  
  <p>Then I can take those deltas and apply them in arbitrary order, either s2_d_s1 first or s3_d_s1 first. So that the following are equal:</p>
  
  <pre><code>apply_delta(apply_delta(s1, s2_d_s1), s3_d_s1) ==
      apply_delta(apply_delta(s1, s3_d_s1), s2_d_s1)
  
  apply_delta(s1, s2_d_s1) == "The green fox jumped over the hill, followed by the crazy clown."
  </code></pre>
  
  <p>How would I do this in Ruby? Is there a library that would do it?</p>
  
  <p>(The actual content is going to be more complex than sentences. It's documents.)</p>
  
  <p>I've tried fossilize but can't figure out how to handle changing sentence size (applying the first delta changes the sentence size, which screws up applying the second delta):</p>
  
  <pre><code>s1 = "The red dog jumped over the hill, followed by the crazy clown."
  s2 = "The green fox jumped over the hill, followed by the crazy clown."
  s3 = "The red dog jumped over the hill, followed by the dumb dolphin."
  s2_d_s1 = Fossilize.create(s1, s2)
  s3_d_s1 = Fossilize.create(s1, s3)
  Fossilize.apply(Fossilize.apply(s1, s2_d_s1), s3_d_s1)
  DeltaApplicationError: Output was -1, but I expected 63!
      from /Users/me/.rvm/gems/ruby-2.2.1/gems/fossilize-1.1.1/lib/fossilize.rb:107:in `apply'
      from (irb):14
      from /Users/me/.rvm/rubies/ruby-2.2.1/bin/irb:11:in `&lt;main&gt;'
  </code></pre>