title: Count Possible Groups Size 2 3 Sum Multiple 3
signature: fun countPossibleGroupsSize23SumMultiple3(arr: ArrayList<Int>, n: Int): Float {
source_py: def count_possible_groups_size_2_3_sum_multiple_3(arr, n):
      c = [0, 0, 0]
      res = 0
      for i in range(0, n):
          c[(arr[i] % 3)] += 1
      res += ((c[0] * (c[0] - 1)) >> 1)
      res += (c[1] * c[2])
      res += (((c[0] * (c[0] - 1)) * (c[0] - 2)) / 6)
      res += (((c[1] * (c[1] - 1)) * (c[1] - 2)) / 6)
      res += (((c[2] * (c[2] - 1)) * (c[2] - 2)) / 6)
      res += ((c[0] * c[1]) * c[2])
      return res
source_cpp: int count_possible_groups_size_2_3_sum_multiple_3(vector<int> arr, int n) {
    int c [ 3 ] = {
      0 },
      i;
      int res = 0;
      for ( i = 0;
      i < n;
      i ++ ) c [ arr [ i ] % 3 ] ++;
      res += ( ( c [ 0 ] * ( c [ 0 ] - 1 ) ) >> 1 );
      res += c [ 1 ] * c [ 2 ];
      res += ( c [ 0 ] * ( c [ 0 ] - 1 ) * ( c [ 0 ] - 2 ) ) / 6;
      res += ( c [ 1 ] * ( c [ 1 ] - 1 ) * ( c [ 1 ] - 2 ) ) / 6;
      res += ( ( c [ 2 ] * ( c [ 2 ] - 1 ) * ( c [ 2 ] - 2 ) ) / 6 );
      res += c [ 0 ] * c [ 1 ] * c [ 2 ];
      return res;
    }
question_info.test_list: [{"idx": 0, "outputs": 90.0, "inputs": {"arr": [1, 3, 6, 12, 18, 31, 36, 43, 47, 59, 64, 64, 69, 69, 94, 98, 98], "n": 12}}, {"idx": 1, "outputs": 655.0, "inputs": {"arr": [94, 46, 64, 18, 70, 22, -98, 52, -26, 34, -22, 22, 40, 66, -72, -66, 86, 84, 12, -38, 28, -60, -10, -30, -78, 76, 62, 74, 24, -64, 0, 92, -20, -66, -52], "n": 23}}, {"idx": 2, "outputs": 3276.0, "inputs": {"arr": [0, 0, 0, 0, 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, 1, 1, 1, 1, 1], "n": 29}}, {"idx": 3, "outputs": 7.0, "inputs": {"arr": [68, 96, 74, 38, 70, 70], "n": 5}}, {"idx": 4, "outputs": 329.0, "inputs": {"arr": [-88, -74, -70, -64, -64, -64, -58, -52, -18, -10, -6, 4, 4, 28, 44, 48, 52, 54, 64, 72, 76, 94], "n": 18}}, {"idx": 5, "outputs": 2310.0, "inputs": {"arr": [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1], "n": 36}}, {"idx": 6, "outputs": 49.0, "inputs": {"arr": [9, 12, 14, 21, 27, 28, 45, 50, 54, 57, 58, 62, 78, 82, 91, 92, 95], "n": 9}}, {"idx": 7, "outputs": 24.0, "inputs": {"arr": [16, -46, -32, -36, -84, -14, -18, 16, 54, 90, -4], "n": 8}}, {"idx": 8, "outputs": 1.0, "inputs": {"arr": [0, 0, 1, 1], "n": 3}}, {"idx": 9, "outputs": 29.0, "inputs": {"arr": [53, 32, 54, 84, 79, 37, 44, 30, 92, 53, 89, 95], "n": 8}}]
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:Float, expected:Float):Boolean{
    return abs(actual - expected) < 1e-06f
  }
  fun driver(arr: ArrayList<Int>, n: Int, expected:Float):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(1, 3, 6, 12, 18, 31, 36, 43, 47, 59, 64, 64, 69, 69, 94, 98, 98), 12, 90.0f)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(94, 46, 64, 18, 70, 22, -98, 52, -26, 34, -22, 22, 40, 66, -72, -66, 86, 84, 12, -38, 28, -60, -10, -30, -78, 76, 62, 74, 24, -64, 0, 92, -20, -66, -52), 23, 655.0f)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 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, 1, 1, 1, 1, 1), 29, 3276.0f)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(68, 96, 74, 38, 70, 70), 5, 7.0f)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-88, -74, -70, -64, -64, -64, -58, -52, -18, -10, -6, 4, 4, 28, 44, 48, 52, 54, 64, 72, 76, 94), 18, 329.0f)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1), 36, 2310.0f)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(9, 12, 14, 21, 27, 28, 45, 50, 54, 57, 58, 62, 78, 82, 91, 92, 95), 9, 49.0f)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(16, -46, -32, -36, -84, -14, -18, 16, 54, 90, -4), 8, 24.0f)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(0, 0, 1, 1), 3, 1.0f)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(53, 32, 54, 84, 79, 37, 44, 30, 92, 53, 89, 95), 8, 29.0f)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: countPossibleGroupsSize23SumMultiple3
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