title: Swap Two Nibbles Byte
signature: func swapTwoNibblesByte(x int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(x int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(x),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(57, 147)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(99, 54)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(66, 36)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(97, 22)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(95, 245)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(42, 162)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(95, 245)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(89, 149)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(3, 48)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(84, 69)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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 );
  }