title: Next Power Of 2 2
signature: func nextPowerOf22(n int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(63, 64)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(78, 128)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(13, 16)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(5, 8)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(34, 64)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(69, 128)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(63, 64)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(78, 128)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(80, 128)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(19, 32)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def next_power_of_2_2(n):
      n -= 1
      n |= (n >> 1)
      n |= (n >> 2)
      n |= (n >> 4)
      n |= (n >> 8)
      n |= (n >> 16)
      n += 1
      return n
source_cpp: unsigned int next_power_of_2_2(unsigned int n) {
    n --;
    n |= n >> 1;
    n |= n >> 2;
    n |= n >> 4;
    n |= n >> 8;
    n |= n >> 16;
    n ++;
    return n;
  }