title: Calculate how many binary numbers with X number of 1 bits exist between two given binary numbers with the same property
body: <p>This has been a challenge for me for some time. </p>
  
  <p>Given two arrays that represent binary numbers, A and C with the same size, consisting of bits represented by the numbers 0 or 1, such that C > A, and both have the same X number of 1 bits, what is the most efficient way to calculate how many binaries B exist, such that A   &lt; B &lt; C, and that every B also has X number of 1 bits?.</p>
  
  <p>Example: For A={0,1,0,0,1} C={1,0,1,0,0} X=2<br>
  All B's would be {0,1,0,1,0},{0,1,1,0,0},{1,0,0,0,1},{1,0,0,1,0}, which would give me the answer 4. There are 4 binaries with 2 '1' bits between 01001 and 10100.</p>
  
  <p>I have an algorithm to generate the next B given some A, but i feel that it wouldnt be efficient to keep generating the next B AND checking if i have hit the C binary yet. </p>
  
  <p>Is there any way to calculate the exact number of B's between A and C without generating the B's?</p>