title: Find A Triplet That Sum To A Given Value
signature: function find_a_triplet_that_sum_to_a_given_value(a, arr_size, sum)
source_py: def find_a_triplet_that_sum_to_a_given_value(A, arr_size, sum):
      for i in range(0, (arr_size - 2)):
          for j in range((i + 1), (arr_size - 1)):
              for k in range((j + 1), arr_size):
                  if (((A[i] + A[j]) + A[k]) == sum):
                      print('Triplet is', A[i], ', ', A[j], ', ', A[k])
                      return True
      return False
source_cpp: bool find_a_triplet_that_sum_to_a_given_value(vector<int> A, int arr_size, int sum) {
    int l, r;
    for ( int i = 0;
    i < arr_size - 2;
    i ++ ) {
      for ( int j = i + 1;
      j < arr_size - 1;
      j ++ ) {
        for ( int k = j + 1;
        k < arr_size;
        k ++ ) {
          if ( A [ i ] + A [ j ] + A [ k ] == sum ) {
            return true;
          }
        }
      }
    }
    return false;
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(a, arr_size, sum, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(a, arr_size, sum) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({15, 18, 38, 47, 75, 88}, 5, 4, false)
      print(string.format("TEST-0...%s",result))
  
      result = driver({28, -2, 62, 38, 86, -86, 56, 58, 96, 6, -28, 8, 68, -16, -80, -4, 98, -92, 4, -4, 58, -62, 46, 64}, 22, 18, true)
      print(string.format("TEST-1...%s",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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 27, 23, false)
      print(string.format("TEST-2...%s",result))
  
      result = driver({19, 77, 17, 91, 6, 35, 22, 4, 30, 23, 97, 56, 78, 16, 22, 23, 95, 57, 43, 27, 47, 44, 23, 10, 3, 94, 55, 22, 93, 32, 89, 28, 64, 22, 13, 24, 38, 44, 6, 1, 80}, 22, 29, true)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-98, -98, -94, -88, -80, -74, -68, -68, -64, -44, -36, -24, -10, -8, -8, 0, 4, 6, 8, 8, 12, 14, 16, 38, 50, 52, 54, 56, 66, 68, 76, 88}, 18, 19, false)
      print(string.format("TEST-4...%s",result))
  
      result = driver({1, 1, 0, 0, 1, 0, 1, 1}, 4, 5, false)
      print(string.format("TEST-5...%s",result))
  
      result = driver({7, 22, 24, 30, 42, 44, 49, 49, 65, 70, 70, 74, 74, 75, 90, 95, 96}, 8, 13, false)
      print(string.format("TEST-6...%s",result))
  
      result = driver({40, -76, -68, -86, -14, 82, -20, 54, -26, 56, -24, -44, 44, 60, 52, -20, 80, -24, -90, -30, -2}, 11, 18, true)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 15, 17, false)
      print(string.format("TEST-8...%s",result))
  
      result = driver({33, 92, 6, 99, 83, 97, 49, 97, 85, 52}, 6, 7, false)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": false, "inputs": {"a": [15, 18, 38, 47, 75, 88], "arr_size": 5, "sum": 4}}, {"idx": 1, "outputs": true, "inputs": {"a": [28, -2, 62, 38, 86, -86, 56, 58, 96, 6, -28, 8, 68, -16, -80, -4, 98, -92, 4, -4, 58, -62, 46, 64], "arr_size": 22, "sum": 18}}, {"idx": 2, "outputs": false, "inputs": {"a": [0, 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], "arr_size": 27, "sum": 23}}, {"idx": 3, "outputs": true, "inputs": {"a": [19, 77, 17, 91, 6, 35, 22, 4, 30, 23, 97, 56, 78, 16, 22, 23, 95, 57, 43, 27, 47, 44, 23, 10, 3, 94, 55, 22, 93, 32, 89, 28, 64, 22, 13, 24, 38, 44, 6, 1, 80], "arr_size": 22, "sum": 29}}, {"idx": 4, "outputs": false, "inputs": {"a": [-98, -98, -94, -88, -80, -74, -68, -68, -64, -44, -36, -24, -10, -8, -8, 0, 4, 6, 8, 8, 12, 14, 16, 38, 50, 52, 54, 56, 66, 68, 76, 88], "arr_size": 18, "sum": 19}}, {"idx": 5, "outputs": false, "inputs": {"a": [1, 1, 0, 0, 1, 0, 1, 1], "arr_size": 4, "sum": 5}}, {"idx": 6, "outputs": false, "inputs": {"a": [7, 22, 24, 30, 42, 44, 49, 49, 65, 70, 70, 74, 74, 75, 90, 95, 96], "arr_size": 8, "sum": 13}}, {"idx": 7, "outputs": true, "inputs": {"a": [40, -76, -68, -86, -14, 82, -20, 54, -26, 56, -24, -44, 44, 60, 52, -20, 80, -24, -90, -30, -2], "arr_size": 11, "sum": 18}}, {"idx": 8, "outputs": false, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], "arr_size": 15, "sum": 17}}, {"idx": 9, "outputs": false, "inputs": {"a": [33, 92, 6, 99, 83, 97, 49, 97, 85, 52], "arr_size": 6, "sum": 7}}]
question_info.extension: lua
question_info.entry_fn_name: find_a_triplet_that_sum_to_a_given_value
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__