title: accounting lettering algorithm to find matching amounts
body: <p>Do you know resources or links who talks about lettering algorithms ?</p>
  
  <p>I need to find positives amounts that matchs with negatives ones to do lettering. For example :</p>
  
  <pre><code>array (
    0 =&gt; 
    array (
      'debit' =&gt; NULL,
      'credit' =&gt; '440'
    ),
    1 =&gt; 
    array (
      'debit' =&gt; '880',
      'credit' =&gt; NULL
    ),
    2 =&gt; 
    array (
      'debit' =&gt; '440',
      'credit' =&gt; NULL
    ),
  )
  </code></pre>
  
  <p>here, indexes 0 and 2 can be associated with index 1, baut i can have more complicated associations</p>
  
  <p>more examples :</p>
  
  <pre><code>     DEBIT        CREDIT
  1       20         
  2                     20
  3       40
  
  result =&gt; 1 / 2
  
       DEBIT        CREDIT
  1       20         
  2       40             
  3                     40
  
  result =&gt; 2 / 3
  
       DEBIT        CREDIT
  1       20         
  2       20         
  3                     20
  4       20
  
  result =&gt; 1 / 3
  
       DEBIT        CREDIT
  1       20         
  2       20         
  3                     20
  4                     40
  5       20
  
  result =&gt; 1-2-5 / 3-4
  </code></pre>
  
  <p>thanks</p>