title: Swap Two Nibbles Byte
signature: function swap_two_nibbles_byte(x)
source_py: def swap_two_nibbles_byte(x):
      return (((x & 15) << 4) | ((x & 240) >> 4))
source_cpp: int swap_two_nibbles_byte(int x) {
    return ( ( x & 0x0F ) << 4 | ( x & 0xF0 ) >> 4 );
  }
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(57, 147)
      print(string.format("TEST-0...%s",result))
  
      result = driver(99, 54)
      print(string.format("TEST-1...%s",result))
  
      result = driver(66, 36)
      print(string.format("TEST-2...%s",result))
  
      result = driver(97, 22)
      print(string.format("TEST-3...%s",result))
  
      result = driver(95, 245)
      print(string.format("TEST-4...%s",result))
  
      result = driver(42, 162)
      print(string.format("TEST-5...%s",result))
  
      result = driver(95, 245)
      print(string.format("TEST-6...%s",result))
  
      result = driver(89, 149)
      print(string.format("TEST-7...%s",result))
  
      result = driver(3, 48)
      print(string.format("TEST-8...%s",result))
  
      result = driver(84, 69)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 147, "inputs": {"x": 57}}, {"idx": 1, "outputs": 54, "inputs": {"x": 99}}, {"idx": 2, "outputs": 36, "inputs": {"x": 66}}, {"idx": 3, "outputs": 22, "inputs": {"x": 97}}, {"idx": 4, "outputs": 245, "inputs": {"x": 95}}, {"idx": 5, "outputs": 162, "inputs": {"x": 42}}, {"idx": 6, "outputs": 245, "inputs": {"x": 95}}, {"idx": 7, "outputs": 149, "inputs": {"x": 89}}, {"idx": 8, "outputs": 48, "inputs": {"x": 3}}, {"idx": 9, "outputs": 69, "inputs": {"x": 84}}]
question_info.extension: lua
question_info.entry_fn_name: swap_two_nibbles_byte
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__