title: Write An Efficient Method To Check If A Number Is Multiple Of 3
signature: function writeAnEfficientMethodToCheckIfANumberIsMultipleOf3(n: number): number {
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.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(94, 0);
    console.log(`TEST-0...${result}`);
  
    result = driver(94, 0);
    console.log(`TEST-1...${result}`);
  
    result = driver(79, 0);
    console.log(`TEST-2...${result}`);
  
    result = driver(39, 1);
    console.log(`TEST-3...${result}`);
  
    result = driver(16, 0);
    console.log(`TEST-4...${result}`);
  
    result = driver(90, 1);
    console.log(`TEST-5...${result}`);
  
    result = driver(64, 0);
    console.log(`TEST-6...${result}`);
  
    result = driver(76, 0);
    console.log(`TEST-7...${result}`);
  
    result = driver(83, 0);
    console.log(`TEST-8...${result}`);
  
    result = driver(47, 0);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: writeAnEfficientMethodToCheckIfANumberIsMultipleOf3
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js