title: Find A Triplet That Sum To A Given Value 1
signature: function find_a_triplet_that_sum_to_a_given_value_1(a, arr_size, sum)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(a, arr_size, sum, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(a, arr_size, sum), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver([28, 47, 65, 89], 3, 3, false);
      @printf("TEST-0...%s\n",result);
      
      result = driver([-90, -88, -88, -70, -66, -64, -64, -56, -52, -48, -42, -40, -26, -16, -14, -8, -2, 0, 6, 12, 12, 14, 18, 46, 50, 52, 52, 52, 58, 68, 70, 70, 74, 78, 84, 96, 98], 22, 24, true);
      @printf("TEST-1...%s\n",result);
      
      result = driver([0], 0, 0, false);
      @printf("TEST-2...%s\n",result);
      
      result = driver([22, 49, 52, 54, 66, 80, 87, 93], 5, 7, false);
      @printf("TEST-3...%s\n",result);
      
      result = driver([-96, -92, -86, -74, -62, -60, -56, -54, -46, -38, -32, -26, -16, -16, -8, -4, 0, 6, 20, 28, 42, 44, 56], 13, 19, false);
      @printf("TEST-4...%s\n",result);
      
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 39, 39, false);
      @printf("TEST-5...%s\n",result);
      
      result = driver([1, 2, 16, 16, 20, 24, 24, 38, 41, 54, 57, 72, 79, 83, 89, 90, 96, 97, 98], 12, 12, false);
      @printf("TEST-6...%s\n",result);
      
      result = driver([-30, 22, 52, 78], 2, 3, false);
      @printf("TEST-7...%s\n",result);
      
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 21, 16, false);
      @printf("TEST-8...%s\n",result);
      
      result = driver([1, 4, 6, 9, 10, 11, 11, 16, 16, 20, 23, 26, 28, 28, 40, 41, 41, 44, 48, 49, 50, 51, 52, 58, 58, 72, 77, 83, 83, 92, 92, 98], 29, 27, true);
      @printf("TEST-9...%s\n",result);
      
  end
  
  main()
source_py: def find_a_triplet_that_sum_to_a_given_value_1(A, arr_size, sum):
      A.sort()
      for i in range(0, (arr_size - 2)):
          l = (i + 1)
          r = (arr_size - 1)
          while (l < r):
              if (((A[i] + A[l]) + A[r]) == sum):
                  print('Triplet is', A[i], ', ', A[l], ', ', A[r])
                  return True
              elif (((A[i] + A[l]) + A[r]) < sum):
                  l += 1
              else:
                  r -= 1
      return False
source_cpp: bool find_a_triplet_that_sum_to_a_given_value_1(vector<int> A, int arr_size, int sum) {
    int l, r;
    sort(A.begin(), A.end());
    for ( int i = 0;
    i < arr_size - 2;
    i ++ ) {
      l = i + 1;
      r = arr_size - 1;
      while ( l < r ) {
        if ( A [ i ] + A [ l ] + A [ r ] == sum ) {
          return true;
        }
        else if ( A [ i ] + A [ l ] + A [ r ] < sum ) l ++;
        else r --;
      }
    }
    return false;
  }