title: Next Power Of 2
signature: next_power_of_2 <- 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(
          74L, 
          128L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          70L, 
          128L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          85L, 
          128L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          78L, 
          128L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          71L, 
          128L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          32L, 
          32L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          97L, 
          128L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          90L, 
          128L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          64L, 
          64L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          48L, 
          64L
      )))
  
  }
  
  main()
source_py: def next_power_of_2(n):
      count = 0
      if (n and (not (n & (n - 1)))):
          return n
      while (n != 0):
          n >>= 1
          count += 1
      return (1 << count)
source_cpp: unsigned int next_power_of_2(unsigned int n) {
    unsigned count = 0;
    if ( n && ! ( n & ( n - 1 ) ) ) return n;
    while ( n != 0 ) {
      n >>= 1;
      count += 1;
    }
    return 1 << count;
  }