Let's say a
and b
are recorded at a constant rate of 2s and 3s respectively:
>>> a
0, 2, 4, 6, 8, 10, 12
>>> b
0, 3, 6, 9, 12
I'd like to write a function in python that returns
- the smallest positive difference (i.e., bigger than zero) of
a-b
, and - the number of instances that takes
b
to reach the same value ofa
.
So in the previous example,
- the smallest difference of
a-b
is 1, that is, whena==4
andb==3
(ora==10
andb==9
) - it takes 3 instances of
b
to reach the same value ofa
(i.e.,0, 3, 6
).
Ideally I'd like to use the function in this manner:
a = 2
b = 3
>>> my_fun(a,b)
>>> [1, 3] #1-smallest difference, 3-number of instances