title: Swap All Odd And Even Bits
signature: class Solution {
  
      public Integer swapAllOddAndEvenBits(Integer x) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer x, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(x,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(99, 147);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(94, 173);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(11, 7);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(3, 3);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(77, 142);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(57, 54);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(54, 57);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(66, 129);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(98, 145);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(36, 24);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer x, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(x),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def swap_all_odd_and_even_bits(x):
      even_bits = (x & 2863311530)
      odd_bits = (x & 1431655765)
      even_bits >>= 1
      odd_bits <<= 1
      return (even_bits | odd_bits)
source_cpp: unsigned int swap_all_odd_and_even_bits(unsigned int x) {
    unsigned int even_bits = x & 0xAAAAAAAA;
    unsigned int odd_bits = x & 0x55555555;
    even_bits >>= 1;
    odd_bits <<= 1;
    return ( even_bits | odd_bits );
  }