input: Write a function to generate a list of all substrings of a given string in descending order of their lengths. The function should return a list containing all substrings from the longest to the shortest. If the input string is empty, the function should return an empty list.
  
  def generate_substrings(string):
      result = []
      n = len(string)
      if n == 0:
          return result
      for l in range(n, 0, -1):
          for i in range(n-l + 1):
              result.append(string[i:i+l])
      return result
  
  assert generate_substrings("abcde")==['abcde', 'abcd', 'bcde', 'abc', 'bcd', 'cde', 'ab', 'bc', 'cd', 'de', 'a', 'b', 'c', 'd', 'e']
  assert generate_substrings("example")==['example', 'exampl', 'xample', 'examp', 'ample', 'exa', 'xam', 'amp', 'mpl', 'ple', 'ex', 'xa', 'am', 'mp', 'pl', 'le', 'e', 'x', 'a', 'm', 'p', 'l', 'e']
  assert generate_substrings("")==[]
  assert generate_substrings("12345")==['12345', '1234', '2345', '123', '234', '345', '12', '23', '34', '45', '1', '2', '3', '4', '5']
output: def generate_substrings(string):
      result = []
      n = len(string)
      if n == 0:
          return result
      for l in range(n, 0, -1):
          for i in range(n-l + 1):
              result.append(string[i:i+l])
      return result