input: def max_triangle_height(red: int, blue: int) -> int:
      """
      Given two integers, red and blue, indicating the number of red and blue balls, arrange them to create a triangle. The arrangement should have 1 ball in the 1st row, 2 balls in the 2nd row, and so forth.
  
      Each row must contain balls of only one color, with alternating colors in consecutive rows.
  
      Return the greatest possible height of such a triangle.
  
      Examples:
      >>> red = 2, blue = 4
      3
      >>> red = 2, blue = 1
      2
  
      Constraints:
      1 <= red, blue <= 100
      """
output:     height = 0
      while True:
          next_row = height + 1
          if next_row % 2 == 1:  # Odd row, place red balls
              if red >= next_row:
                  red -= next_row
                  height += 1
              else:
                  break
          else:  # Even row, place blue balls
              if blue >= next_row:
                  blue -= next_row
                  height += 1
              else:
                  break
      return height