title: Next Power Of 2
signature: fun nextPowerOf2(n: Int): Int {
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(74, 128)
      println("TEST-0...${result}")
      
      result = driver(70, 128)
      println("TEST-1...${result}")
      
      result = driver(85, 128)
      println("TEST-2...${result}")
      
      result = driver(78, 128)
      println("TEST-3...${result}")
      
      result = driver(71, 128)
      println("TEST-4...${result}")
      
      result = driver(32, 32)
      println("TEST-5...${result}")
      
      result = driver(97, 128)
      println("TEST-6...${result}")
      
      result = driver(90, 128)
      println("TEST-7...${result}")
      
      result = driver(64, 64)
      println("TEST-8...${result}")
      
      result = driver(48, 64)
      println("TEST-9...${result}")
      
          
  }
  
  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;
  }