title: Swap Two Nibbles Byte
signature: function swapTwoNibblesByte(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(57, 147);
    console.log(`TEST-0...${result}`);
  
    result = driver(99, 54);
    console.log(`TEST-1...${result}`);
  
    result = driver(66, 36);
    console.log(`TEST-2...${result}`);
  
    result = driver(97, 22);
    console.log(`TEST-3...${result}`);
  
    result = driver(95, 245);
    console.log(`TEST-4...${result}`);
  
    result = driver(42, 162);
    console.log(`TEST-5...${result}`);
  
    result = driver(95, 245);
    console.log(`TEST-6...${result}`);
  
    result = driver(89, 149);
    console.log(`TEST-7...${result}`);
  
    result = driver(3, 48);
    console.log(`TEST-8...${result}`);
  
    result = driver(84, 69);
    console.log(`TEST-9...${result}`);
  
    process.exit(0);
  };
  
  if (require.main === module) {
    main();
  }
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 );
  }