code: def substrings_indexes(seq, reverse=False):
      
      r = range(1, len(seq) + 1)
      if reverse:
          r = reversed(r)
      return (
          (seq[i:i + L], i, i + L) for L in r for i in range(len(seq) - L + 1)
      )
docs: Yield all substrings and their positions in *seq*
  
      The items yielded will be a tuple of the form ``(substr, i, j)``, where
      ``substr == seq[i:j]``.
  
      This function only works for iterables that support slicing, such as
      ``str`` objects.
  
      >>> for item in substrings_indexes('more'):
      ...    print(item)
      ('m', 0, 1)
      ('o', 1, 2)
      ('r', 2, 3)
      ('e', 3, 4)
      ('mo', 0, 2)
      ('or', 1, 3)
      ('re', 2, 4)
      ('mor', 0, 3)
      ('ore', 1, 4)
      ('more', 0, 4)
  
      Set *reverse* to ``True`` to yield the same items in the opposite order.