title: Producing combinations from a list
body: <p>I have the following code:</p>
  
  <pre>
  
  def produceCombinations(text, maximumWindowWidth)
  
    combinations = []
  
    for windowWidth in range(1,maximumWindowWidth+1):
      for startingIndex in range(len(text)-windowWidth+1):
        combinations.append((text[startingIndex:startingIndex+windowWidth]))
  
    return combinations
  
  produceCombinations(("1","2","3","4","5","6",),3)
  
  </pre>
  
  <p>which gives the following output:</p>
  
  <pre>
  ('1',)
  ('2',)
  ('3',)
  ('4',)
  ('5',)
  ('6',)
  ('1', '2')
  ('2', '3')
  ('3', '4')
  ('4', '5')
  ('5', '6')
  ('1', '2', '3')
  ('2', '3', '4')
  ('3', '4', '5')
  ('4', '5', '6')
  </pre>
  
  <p>However I also want this algorithm to give me the additional combinations:</p>
  
  <pre>
  ('1', '3') # hop of 1
  ('2', '4')
  ('3', '5')
  ('4', '6')
  ('1', '4') # hop of 2
  ('2', '5')
  ('3', '6')
  ('4', '7')
  ('1', '3', '4') # hop of 1 and 0
  ('2', '4', '5')
  ('3', '5', '6')
  ('1', '2', '4') # hop of 0 and 1
  ('2', '3', '5') 
  ('3', '4', '6')
  ('1', '3', '5') # hop of 1 and 1
  ('2', '4', '6')
  ('1', '2', '5') # hop of 0 and 2
  ('2', '3', '6')
  ('1', '3', '6') # hop of 1 and 2
  ('1', '4', '5') # hop of 2 and 0
  ('2', '5', '6')
  ('1', '4', '6') # hop of 2 and 1
  </pre>
  
  <p>where my function will have a new argument called maximumHop so as to limit the number of these extra combinations. For the above example the maximumHop is two since the combination ('1', '5') is not possible.</p>
  
  <p>Any suggestions regarding a nice way to do this?</p>
  
  <p>Thanks,</p>
  
  <p>Barry</p>