title: Swap Two Nibbles Byte
signature: function swapTwoNibblesByte($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(
        57, 
        147));
      
      printf("TEST-1...%s\n",driver(
        99, 
        54));
      
      printf("TEST-2...%s\n",driver(
        66, 
        36));
      
      printf("TEST-3...%s\n",driver(
        97, 
        22));
      
      printf("TEST-4...%s\n",driver(
        95, 
        245));
      
      printf("TEST-5...%s\n",driver(
        42, 
        162));
      
      printf("TEST-6...%s\n",driver(
        95, 
        245));
      
      printf("TEST-7...%s\n",driver(
        89, 
        149));
      
      printf("TEST-8...%s\n",driver(
        3, 
        48));
      
      printf("TEST-9...%s\n",driver(
        84, 
        69));
      
  }
  
  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 );
  }