title: function returning the smallest difference between elements of two lists - python
body: <p>Let's say <code>a</code> and <code>b</code> are recorded at a constant rate of 2s and 3s respectively:</p>
  
  <pre><code>&gt;&gt;&gt; a
  0, 2, 4, 6, 8, 10, 12
  &gt;&gt;&gt; b
  0, 3, 6, 9, 12
  </code></pre>
  
  <p>I'd like to write a function in python that returns </p>
  
  <ol>
  <li>the smallest positive difference (i.e., bigger than zero) of <code>a-b</code>, and </li>
  <li>the number of instances that takes <code>b</code> to reach the same value of <code>a</code>.</li>
  </ol>
  
  <p>So in the previous example, </p>
  
  <ol>
  <li>the smallest difference of <code>a-b</code> is 1, that is, when <code>a==4</code> and <code>b==3</code> (or <code>a==10</code> and <code>b==9</code>)</li>
  <li>it takes 3 instances of <code>b</code> to reach the same value of <code>a</code> (i.e., <code>0, 3, 6</code>). </li>
  </ol>
  
  <p>Ideally I'd like to use the function in this manner:</p>
  
  <pre><code>a = 2
  b = 3
  &gt;&gt;&gt; my_fun(a,b)
  &gt;&gt;&gt; [1, 3] #1-smallest difference, 3-number of instances
  </code></pre>