title: Minimum Xor Value Pair 1
signature: func minimumXorValuePair1(arr []int, n 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(arr []int, n int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(arr, n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver([]int{8, 11, 12, 27, 32, 32, 36, 56, 57, 66, 68, 70, 74, 78, 82, 83, 96}, 
  	10, 0)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver([]int{-60, -8, 4, 38, 40, 42, 48, 66}, 
  	7, -4)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver([]int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 
  	19, 0)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver([]int{2, 3, 4, 6, 7, 7, 10, 11, 12, 15, 16, 20, 24, 28, 29, 32, 36, 37, 38, 44, 48, 49, 50, 52, 57, 57, 57, 61, 63, 64, 65, 66, 67, 68, 70, 76, 78, 81, 82, 86, 87, 89, 91, 95, 95, 98}, 
  	36, 0)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver([]int{-88, -84, -76, -58, -40, -38, -28, -24, -20, -14, -12, 16, 20, 28, 28, 30, 40, 44, 56, 58, 60, 92, 92}, 
  	13, -28)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver([]int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 
  	20, 0)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver([]int{6, 6, 19, 31, 41, 45, 49, 56, 78, 96, 98}, 
  	6, 0)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver([]int{-90, -84, -4, 22, 62}, 
  	3, 10)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver([]int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 
  	21, 0)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver([]int{7, 10, 13, 20, 28, 29, 34, 37, 39, 42, 43, 56, 58, 65, 69, 72, 74, 83, 91, 92, 93, 99}, 
  	14, 1)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def minimum_xor_value_pair_1(arr, n):
      arr.sort()
      minXor = int(sys.float_info.max)
      val = 0
      for i in range(0, (n - 1)):
          val = (arr[i] ^ arr[(i + 1)])
          minXor = min(minXor, val)
      return minXor
source_cpp: int minimum_xor_value_pair_1(vector<int> arr, int n) {
    sort(arr.begin(), arr.end());
    int minXor = INT_MAX;
    int val = 0;
    for ( int i = 0;
    i < n - 1;
    i ++ ) {
      val = arr [ i ] ^ arr [ i + 1 ];
      minXor = min ( minXor, val );
    }
    return minXor;
  }