input: def tribonacci_sequence(n):
      """The well-known Fibonacci sequence has been extensively studied by mathematicians over the centuries. 
      However, the Tribonacci sequence is less commonly known. It follows these rules of recurrence:
      tribonacci_sequence(1) = 3
      tribonacci_sequence(n) = 1 + n / 2, for even n.
      tribonacci_sequence(n) = tribonacci_sequence(n - 1) + tribonacci_sequence(n - 2) + tribonacci_sequence(n + 1), for odd n.
      For example:
      tribonacci_sequence(2) = 1 + (2 / 2) = 2
      tribonacci_sequence(4) = 3
      tribonacci_sequence(3) = tribonacci_sequence(2) + tribonacci_sequence(1) + tribonacci_sequence(4)
                             = 2 + 3 + 3 = 8 
      Given a non-negative integer n, the function should return a list of the first n + 1 numbers in the Tribonacci sequence.
      Examples:
      tribonacci_sequence(3) = [1, 3, 2, 8]
      """
output:     def tribonacci_sequence(n):
      result = []
      for i in range(n + 1):
          if i == 0:
              result.append(1)
          elif i == 1:
              result.append(3)
          elif i % 2 == 0:
              result.append(1 + i // 2)
          else:
              result.append(result[i - 1] + result[i - 2] + result[i + 1])
      return result
  
  # Testing the function with provided examples
  print(tribonacci_sequence(3)) # Should print [1, 3, 2, 8]