title: Write An Efficient Method To Check If A Number Is Multiple Of 3
signature: fun writeAnEfficientMethodToCheckIfANumberIsMultipleOf3(n: Int): Int {
source_py: def write_an_efficient_method_to_check_if_a_number_is_multiple_of_3(n):
      odd_count = 0
      even_count = 0
      if (n < 0):
          n = (- n)
      if (n == 0):
          return 1
      if (n == 1):
          return 0
      while n:
          if (n & 1):
              odd_count += 1
          if (n & 2):
              even_count += 1
          n = (n >> 2)
      return write_an_efficient_method_to_check_if_a_number_is_multiple_of_3(abs((odd_count - even_count)))
source_cpp: int write_an_efficient_method_to_check_if_a_number_is_multiple_of_3(int n) {
    int odd_count = 0;
    int even_count = 0;
    if ( n < 0 ) n = - n;
    if ( n == 0 ) return 1;
    if ( n == 1 ) return 0;
    while ( n ) {
      if ( n & 1 ) odd_count ++;
      if ( n & 2 ) even_count ++;
      n = n >> 2;
    }
    return write_an_efficient_method_to_check_if_a_number_is_multiple_of_3 ( abs ( odd_count - even_count ) );
  }
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"n": 94}}, {"idx": 1, "outputs": 0, "inputs": {"n": 94}}, {"idx": 2, "outputs": 0, "inputs": {"n": 79}}, {"idx": 3, "outputs": 1, "inputs": {"n": 39}}, {"idx": 4, "outputs": 0, "inputs": {"n": 16}}, {"idx": 5, "outputs": 1, "inputs": {"n": 90}}, {"idx": 6, "outputs": 0, "inputs": {"n": 64}}, {"idx": 7, "outputs": 0, "inputs": {"n": 76}}, {"idx": 8, "outputs": 0, "inputs": {"n": 83}}, {"idx": 9, "outputs": 0, "inputs": {"n": 47}}]
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:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(94, 0)
      println("TEST-0...${result}")
      
      result = driver(94, 0)
      println("TEST-1...${result}")
      
      result = driver(79, 0)
      println("TEST-2...${result}")
      
      result = driver(39, 1)
      println("TEST-3...${result}")
      
      result = driver(16, 0)
      println("TEST-4...${result}")
      
      result = driver(90, 1)
      println("TEST-5...${result}")
      
      result = driver(64, 0)
      println("TEST-6...${result}")
      
      result = driver(76, 0)
      println("TEST-7...${result}")
      
      result = driver(83, 0)
      println("TEST-8...${result}")
      
      result = driver(47, 0)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: writeAnEfficientMethodToCheckIfANumberIsMultipleOf3
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