title: Maximum Triplet Sum Array
signature: maximum_triplet_sum_array <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(6L, 10L, 14L, 19L, 24L, 29L, 42L, 43L, 44L, 47L, 47L, 55L, 57L, 59L, 60L, 61L, 76L, 76L, 77L, 81L, 84L, 92L, 92L, 93L, 95L, 97L), 15L, 
          176L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-98L, 72L, 52L, -62L, 74L, -26L, -82L, -74L, 90L, 58L, 94L, -2L, 76L, -28L, 12L, 64L, -94L, 86L, 56L, 10L, 40L, 20L, 92L, -4L, -80L, 26L, -40L, 36L, 66L, -46L, 4L, -42L, -76L, 76L, -90L, -48L, 22L, 30L, 48L, 38L, 78L), 28L, 
          276L
      )))
  
      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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 22L, 
          3L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(96L, 96L, 38L, 26L, 2L, 36L, 15L, 51L, 78L, 98L, 94L, 31L, 62L, 21L, 7L, 68L, 37L, 4L), 10L, 
          290L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-8L, 12L, 68L, 78L, 78L), 4L, 
          158L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), 35L, 
          3L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(1L, 15L, 16L, 17L, 28L, 28L, 28L, 30L, 31L, 37L, 38L, 38L, 45L, 45L, 46L, 46L, 50L, 51L, 53L, 53L, 55L, 55L, 56L, 58L, 58L, 64L, 78L, 82L, 82L, 85L, 87L, 89L, 89L, 90L, 94L, 95L), 29L, 
          242L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-56L, -72L, -20L, 88L, 20L, 86L, 30L, 36L, -44L, -66L, -26L, -88L, 12L, -76L, 78L, 62L, 62L, 68L, -34L, 0L, -22L, 64L, 72L, 56L, -64L, -16L, -4L, 86L, 0L, 98L, -70L, 98L, -68L, 92L, -84L, -56L, 28L, -74L, 6L, -10L, -82L, 36L, -12L, -26L, 66L, -60L, -68L, 70L, 2L), 36L, 
          288L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 11L, 
          2L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(85L, 31L, 15L, 68L, 92L, 89L, 32L, 56L, 27L, 70L, 82L, 58L, 63L, 83L, 89L, 95L, 78L, 9L, 27L, 34L, 24L, 42L, 66L, 6L, 1L, 71L, 55L, 23L, 75L, 26L, 19L, 58L, 25L), 16L, 
          276L
      )))
  
  }
  
  main()
source_py: def maximum_triplet_sum_array(arr, n):
      sm = (- 1000000)
      for i in range(0, n):
          for j in range((i + 1), n):
              for k in range((j + 1), n):
                  if (sm < ((arr[i] + arr[j]) + arr[k])):
                      sm = ((arr[i] + arr[j]) + arr[k])
      return sm
source_cpp: int maximum_triplet_sum_array(vector<int> arr, int n) {
    int sum = INT_MIN;
    for ( int i = 0;
    i < n;
    i ++ ) for ( int j = i + 1;
    j < n;
    j ++ ) for ( int k = j + 1;
    k < n;
    k ++ ) if ( sum < arr [ i ] + arr [ j ] + arr [ k ] ) sum = arr [ i ] + arr [ j ] + arr [ k ];
    return sum;
  }