title: Eliminating Consecutive Numbers
body: <p>If you have a range of numbers from 1-49 with 6 numbers to choose from, there are nearly 14 million combinations. Using my current script, I currently have only 7.2 million combinations remaining. Of the 7.2 million remaining combinations, I want to eliminate all 3, 4, 5, 6, dual, and triple consecutive numbers. 
  Example:</p>
  
  <ul>
  <li>3 consecutive: 1, 2, 3, x, x, x</li>
  <li>4 consecutive: 3, 4, 5, 6, x, x</li>
  <li>5 consecutive: 4, 5, 6, 7, 8, x</li>
  <li>6 consecutive: 5, 6, 7, 8, 9, 10</li>
  <li>double separate consecutive: 1, 2, 5, 6, 14, 18</li>
  <li>triple separate consecutive: 1, 2, 9, 10, 22, 23</li>
  </ul>
  
  <p>Note: combinations such as 1, 2, 12, 13, 14, 15 must also be eliminated or else they conflict with the rule that double and triple consecutive combinations to be eliminated. </p>
  
  <p>I'm looking to find how many combinations of the 7.2 million remaining combinations have zero consecutive numbers (all mixed) and only 1 consecutive pair.</p>
  
  <p>Thank you!</p>
  
  <pre class="lang-py prettyprint-override"><code>import functools
  
  _MIN_SUM     = 120
  _MAX_SUM     = 180
  _MIN_NUM     = 1
  _MAX_NUM     = 49
  _NUM_CHOICES = 6
  _MIN_ODDS    = 2
  _MAX_ODDS    = 4
  
  @functools.lru_cache(maxsize=None)
  def f(n, l, s = 0, odds = 0):
      if s &gt; _MAX_SUM or odds &gt; _MAX_ODDS:
          return 0
      if n == 0 :
          return int(s &gt;= _MIN_SUM and odds &gt;= _MIN_ODDS)
      return sum(f(n-1, i+1, s+i, odds + i % 2) for i in range(l, _MAX_NUM+1))
  
  
  result = f(_NUM_CHOICES, _MIN_NUM)
  
  print('Number of choices = {}'.format(result))
  </code></pre>