title: Swap Two Nibbles Byte
signature: swap_two_nibbles_byte <- function(x) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(x, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(x), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          57L, 
          147L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          99L, 
          54L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          66L, 
          36L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          97L, 
          22L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          95L, 
          245L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          42L, 
          162L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          95L, 
          245L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          89L, 
          149L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          3L, 
          48L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          84L, 
          69L
      )))
  
  }
  
  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 );
  }