input: def max_triangle_height(red: int, blue: int) -> int:
      """
      Given two integers red and blue representing the number of red and blue balls, arrange them to form a triangle where the 1st row has 1 ball, the 2nd row has 2 balls, and so on.
  
      Each row must consist of balls of the same color, and consecutive rows must alternate colors.
  
      Calculate the maximum possible height of the triangle.
  
      Examples:
      >>> red = 2, blue = 4
      3
      >>> red = 2, blue = 1
      2
  
      Constraints:
      1 <= red, blue <= 100
      """
output:     
      height = 0
      while True:
          if height % 2 == 0:
              if red >= height + 1:
                  red -= height + 1
                  height += 1
              else:
                  break
          else:
              if blue >= height + 1:
                  blue -= height + 1
                  height += 1
              else:
                  break
      return height
  