title: Math formula behind this find_single_in_triplets() function?
body: <p>I came across this interesting function, which is to find the only single number (appear once) in an integer list, all other numbers are positive and appears as triplets (3 occurrences).
  It works fine as the example shown below.</p>
  <p>However, I cannot figure out what is the <strong>math formula</strong> that it's derived from.  Hope someone can shed the light on this puzzle.</p>
  <pre><code>def find_single_in_triplets(L):
      orig_sum = sum(L)
      set_sum  = sum(set(L) 
      return (set_sum * 3  - orig_sum) // 2    # given the single num. 
  
  find_single_in_triples([1, 2, 3, 4, 6, 2, 3, 4, 1, 3, 2, 1, 4])  # -&gt; 6
  </code></pre>