title: Swap All Odd And Even Bits
signature: function swapAllOddAndEvenBits($x) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($x, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($x), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        99, 
        147));
      
      printf("TEST-1...%s\n",driver(
        94, 
        173));
      
      printf("TEST-2...%s\n",driver(
        11, 
        7));
      
      printf("TEST-3...%s\n",driver(
        3, 
        3));
      
      printf("TEST-4...%s\n",driver(
        77, 
        142));
      
      printf("TEST-5...%s\n",driver(
        57, 
        54));
      
      printf("TEST-6...%s\n",driver(
        54, 
        57));
      
      printf("TEST-7...%s\n",driver(
        66, 
        129));
      
      printf("TEST-8...%s\n",driver(
        98, 
        145));
      
      printf("TEST-9...%s\n",driver(
        36, 
        24));
      
  }
  
  main();
  ?>
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 );
  }