title: Divisibility 9 Using Bitwise Operators
signature: divisibility_9_using_bitwise_operators <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          96L, 
          FALSE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          85L, 
          FALSE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          54L, 
          TRUE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          14L, 
          FALSE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          47L, 
          FALSE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          11L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          49L, 
          FALSE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          99L, 
          TRUE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          28L, 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          82L, 
          FALSE
      )))
  
  }
  
  main()
source_py: def divisibility_9_using_bitwise_operators(n):
      if ((n == 0) or (n == 9)):
          return True
      if (n < 9):
          return False
      return divisibility_9_using_bitwise_operators((int((n >> 3)) - int((n & 7))))
source_cpp: bool divisibility_9_using_bitwise_operators(int n) {
    if ( n == 0 || n == 9 ) return true;
    if ( n < 9 ) return false;
    return divisibility_9_using_bitwise_operators ( ( int ) ( n >> 3 ) - ( int ) ( n & 7 ) );
  }