title: Find A Triplet That Sum To A Given Value 2
signature: fun findATripletThatSumToAGivenValue2(a: ArrayList<Int>, arr_size: Int, sum: Int): Boolean {
source_py: def find_a_triplet_that_sum_to_a_given_value_2(A, arr_size, sum):
      for i in range(0, (arr_size - 1)):
          s = set()
          curr_sum = (sum - A[i])
          for j in range((i + 1), arr_size):
              if ((curr_sum - A[j]) in s):
                  print('Triplet is', A[i], ', ', A[j], ', ', (curr_sum - A[j]))
                  return True
              s.add(A[j])
      return False
source_cpp: bool find_a_triplet_that_sum_to_a_given_value_2(vector<int> A, int arr_size, int sum) {
    for ( int i = 0;
    i < arr_size - 2;
    i ++ ) {
      unordered_set < int > s;
      int curr_sum = sum - A [ i ];
      for ( int j = i + 1;
      j < arr_size;
      j ++ ) {
        if ( s . find ( curr_sum - A [ j ] ) != s . end ( ) ) {
          return true;
        }
        s . insert ( A [ j ] );
      }
    }
    return false;
  }
question_info.test_list: [{"idx": 0, "outputs": true, "inputs": {"a": [1, 6, 8, 8, 9, 11, 13, 13, 15, 17, 21, 24, 38, 38, 42, 43, 46, 46, 47, 54, 55, 56, 57, 58, 60, 60, 60, 62, 63, 63, 65, 66, 67, 67, 69, 81, 84, 84, 85, 86, 95, 99], "arr_size": 27, "sum": 24}}, {"idx": 1, "outputs": true, "inputs": {"a": [20, -86, -24, 38, -32, -64, -72, 72, 68, 94, 18, -60, -4, -18, -18, -70, 6, -86, 46, -16, 46, -28], "arr_size": 21, "sum": 20}}, {"idx": 2, "outputs": false, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], "arr_size": 17, "sum": 13}}, {"idx": 3, "outputs": false, "inputs": {"a": [13, 96, 31, 39, 23, 39, 50, 10, 21, 64, 41, 54, 44, 97, 24, 91, 79, 86, 38, 49, 77, 71, 8, 98, 85, 36, 37, 65, 42, 48], "arr_size": 17, "sum": 18}}, {"idx": 4, "outputs": false, "inputs": {"a": [-86, -68, -58, -56, -54, -54, -48, -40, -36, -32, -26, -16, -14, -12, -12, -4, -4, -4, 0, 10, 22, 22, 30, 54, 62, 68, 88, 88], "arr_size": 21, "sum": 25}}, {"idx": 5, "outputs": true, "inputs": {"a": [0, 1, 1, 1, 1, 0, 0], "arr_size": 5, "sum": 3}}, {"idx": 6, "outputs": false, "inputs": {"a": [8, 8, 9, 13, 20, 24, 29, 52, 53, 96], "arr_size": 9, "sum": 8}}, {"idx": 7, "outputs": true, "inputs": {"a": [18, -92, -10, 26, 58, -48, 38, 66, -98, -72, 4, 76, -52, 20, 60, -56, 96, 60, -10, -26, -64, -66, -22, -86, 74, 82, 2, -14, 76, 82, 40, 70, -40, -2, -46, -38, 22, 98, 58], "arr_size": 30, "sum": 30}}, {"idx": 8, "outputs": false, "inputs": {"a": [1, 1, 1, 1], "arr_size": 2, "sum": 2}}, {"idx": 9, "outputs": false, "inputs": {"a": [72], "arr_size": 0, "sum": 0}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Boolean, expected:Boolean):Boolean{
    return actual.equals(expected)
  }
  fun driver(a: ArrayList<Int>, arr_size: Int, sum: Int, expected:Boolean):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(a, arr_size, sum), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(1, 6, 8, 8, 9, 11, 13, 13, 15, 17, 21, 24, 38, 38, 42, 43, 46, 46, 47, 54, 55, 56, 57, 58, 60, 60, 60, 62, 63, 63, 65, 66, 67, 67, 69, 81, 84, 84, 85, 86, 95, 99), 27, 24, true)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(20, -86, -24, 38, -32, -64, -72, 72, 68, 94, 18, -60, -4, -18, -18, -70, 6, -86, 46, -16, 46, -28), 21, 20, true)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1), 17, 13, false)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(13, 96, 31, 39, 23, 39, 50, 10, 21, 64, 41, 54, 44, 97, 24, 91, 79, 86, 38, 49, 77, 71, 8, 98, 85, 36, 37, 65, 42, 48), 17, 18, false)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-86, -68, -58, -56, -54, -54, -48, -40, -36, -32, -26, -16, -14, -12, -12, -4, -4, -4, 0, 10, 22, 22, 30, 54, 62, 68, 88, 88), 21, 25, false)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(0, 1, 1, 1, 1, 0, 0), 5, 3, true)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(8, 8, 9, 13, 20, 24, 29, 52, 53, 96), 9, 8, false)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(18, -92, -10, 26, 58, -48, 38, 66, -98, -72, 4, 76, -52, 20, 60, -56, 96, 60, -10, -26, -64, -66, -22, -86, 74, 82, 2, -14, 76, 82, 40, 70, -40, -2, -46, -38, 22, 98, 58), 30, 30, true)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(1, 1, 1, 1), 2, 2, false)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(72), 0, 0, false)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: findATripletThatSumToAGivenValue2
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn