<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generateHOSequence(sequence, symbolsPerSequence, numColumns, sparsity):
 """ Generates a high-order sequence by taking an initial sequence and the changing its first and last SDRs by random SDRs @param sequence (array) sequence to be randomized @param symbolsPerSequence (int) number of symbols per sequence @param numColumns (int) number of columns in the TM @param sparsity (float) percentage of sparsity @return randomizedSequence (array) sequence that contains p percentage of new SDRs """

  sequenceHO = []
  sparseCols = int(numColumns * sparsity)
  for symbol in range(symbolsPerSequence):
    if symbol == 0 or symbol == (symbolsPerSequence - 1):
      sequenceHO.append(generateRandomSymbol(numColumns, sparseCols))
    else:
      sequenceHO.append(sequence[symbol])
  return sequenceHO