title: Swap All Odd And Even Bits
signature: function swapAllOddAndEvenBits(x) {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value) {
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual, expected){
      return convertToString(actual)===convertToString(expected);
  }
  
  function driver(x, expected){
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(x),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(99, 147);
    console.log(`TEST-0...${result}`);
  
    result = driver(94, 173);
    console.log(`TEST-1...${result}`);
  
    result = driver(11, 7);
    console.log(`TEST-2...${result}`);
  
    result = driver(3, 3);
    console.log(`TEST-3...${result}`);
  
    result = driver(77, 142);
    console.log(`TEST-4...${result}`);
  
    result = driver(57, 54);
    console.log(`TEST-5...${result}`);
  
    result = driver(54, 57);
    console.log(`TEST-6...${result}`);
  
    result = driver(66, 129);
    console.log(`TEST-7...${result}`);
  
    result = driver(98, 145);
    console.log(`TEST-8...${result}`);
  
    result = driver(36, 24);
    console.log(`TEST-9...${result}`);
  
    process.exit(0);
  };
  
  if (require.main === module) {
    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 );
  }