title: Swap All Odd And Even Bits
signature: function swap_all_odd_and_even_bits(x)
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 );
  }
question_info.entry_fn_name: swap_all_odd_and_even_bits
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(x, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(x) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(99, 147)
      print(string.format("TEST-0...%s",result))
  
      result = driver(94, 173)
      print(string.format("TEST-1...%s",result))
  
      result = driver(11, 7)
      print(string.format("TEST-2...%s",result))
  
      result = driver(3, 3)
      print(string.format("TEST-3...%s",result))
  
      result = driver(77, 142)
      print(string.format("TEST-4...%s",result))
  
      result = driver(57, 54)
      print(string.format("TEST-5...%s",result))
  
      result = driver(54, 57)
      print(string.format("TEST-6...%s",result))
  
      result = driver(66, 129)
      print(string.format("TEST-7...%s",result))
  
      result = driver(98, 145)
      print(string.format("TEST-8...%s",result))
  
      result = driver(36, 24)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 147, "inputs": {"x": 99}}, {"idx": 1, "outputs": 173, "inputs": {"x": 94}}, {"idx": 2, "outputs": 7, "inputs": {"x": 11}}, {"idx": 3, "outputs": 3, "inputs": {"x": 3}}, {"idx": 4, "outputs": 142, "inputs": {"x": 77}}, {"idx": 5, "outputs": 54, "inputs": {"x": 57}}, {"idx": 6, "outputs": 57, "inputs": {"x": 54}}, {"idx": 7, "outputs": 129, "inputs": {"x": 66}}, {"idx": 8, "outputs": 145, "inputs": {"x": 98}}, {"idx": 9, "outputs": 24, "inputs": {"x": 36}}]