title: Maximum Height Of Triangular Arrangement Of Array Values 1
signature: maximum_height_of_triangular_arrangement_of_array_values_1 <- function(a, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(a, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(a, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(1L, 2L, 2L, 3L, 5L, 6L, 7L, 8L, 8L, 12L, 15L, 16L, 18L, 18L, 20L, 21L, 21L, 22L, 22L, 24L, 24L, 25L, 30L, 35L, 42L, 49L, 52L, 55L, 55L, 63L, 68L, 70L, 72L, 73L, 77L, 80L, 83L, 87L, 87L, 88L, 88L, 94L, 95L, 97L), 22L, 
          6L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(48L, -72L, 84L, -24L, 28L, 94L, 36L, 28L, 32L, 66L, -62L, 64L, 6L, -68L, -12L, 46L, 4L, 98L, 18L, 86L, -60L, 76L, 14L, 98L), 12L, 
          4L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 25L, 
          6L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(11L, 16L, 84L, 8L, 86L, 44L, 79L, 11L, 73L, 12L, 29L, 62L, 22L, 44L, 28L, 8L, 48L, 92L, 73L, 63L, 59L, 44L, 95L, 66L), 14L, 
          4L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-94L, -94L, -92L, -88L, -86L, -82L, -80L, -80L, -78L, -76L, -56L, -56L, -50L, -44L, -42L, -36L, -36L, -32L, -32L, -26L, -14L, -12L, -6L, 12L, 24L, 28L, 34L, 38L, 42L, 42L, 46L, 50L, 56L, 62L, 62L, 74L, 84L, 92L, 94L), 19L, 
          5L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L), 24L, 
          6L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(2L, 2L, 3L, 3L, 3L, 4L, 5L, 13L, 16L, 18L, 21L, 22L, 27L, 28L, 32L, 34L, 36L, 37L, 41L, 42L, 43L, 51L, 52L, 52L, 54L, 54L, 61L, 65L, 67L, 67L, 68L, 71L, 75L, 77L, 77L, 78L, 80L, 81L, 81L, 84L, 86L, 90L, 90L, 93L, 93L, 94L, 99L, 99L), 31L, 
          7L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(54L, -86L), 1L, 
          1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 1L), 1L, 
          1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(5L, 54L, 49L, 80L, 56L, 62L, 31L, 49L, 60L, 19L, 45L, 94L, 33L, 46L, 32L), 8L, 
          3L
      )))
  
  }
  
  main()
source_py: def maximum_height_of_triangular_arrangement_of_array_values_1(a, n):
      return (((- 1) + int(math.sqrt((1 + (8 * n))))) // 2)
source_cpp: int maximum_height_of_triangular_arrangement_of_array_values_1(vector<int> a, int n) {
    return floor ( ( - 1 + sqrt ( 1 + ( 8 * n ) ) ) / 2 );
  }