title: Find The Missing Number 2
signature: find_the_missing_number_2 <- function(a, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(a, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(a, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(2L, 5L, 7L, 8L, 10L, 14L, 27L, 32L, 51L, 52L, 57L, 58L, 65L, 68L, 68L, 72L, 73L, 73L, 83L, 92L, 98L), 12L, 
          50L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-60L, -48L, 38L, -78L, 88L, 86L, -4L, -94L, 16L, -64L, 32L, 88L, 58L, -78L, -16L, 48L, 38L, 30L, 66L, -60L, 20L, 40L, -28L, -64L, -48L, -86L, -80L, -8L, -58L, 52L, 80L, -32L, 46L, -4L, -70L, 76L, -4L, 78L, -64L, 38L, -40L), 28L, 
          -91L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 38L, 
          1L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(69L, 59L, 22L, 33L, 69L, 28L, 11L, 34L, 72L, 88L, 16L, 30L, 69L, 89L, 43L, 4L, 65L, 85L, 27L), 13L, 
          109L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-98L, -98L, -92L, -88L, -88L, -82L, -74L, -70L, -68L, -60L, -60L, -48L, -38L, -34L, -34L, -24L, 14L, 38L, 50L, 58L, 62L, 64L, 64L, 68L, 76L, 78L, 78L, 86L, 88L, 90L, 92L, 98L, 98L), 23L, 
          94L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 0L), 41L, 
          42L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(1L, 9L, 12L, 12L, 24L, 25L, 33L, 33L, 36L, 39L, 46L, 48L, 48L, 52L, 52L, 53L, 57L, 69L, 71L, 72L, 75L, 76L, 78L, 80L, 82L, 86L, 89L, 91L, 94L, 95L, 96L, 97L, 98L, 99L), 30L, 
          124L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(62L, -66L, 60L, -92L, 46L, 6L, -52L, 48L, 72L, -64L, 34L, 20L, 50L, 70L, -34L, 20L, -70L, 14L, -44L, 66L, -70L), 17L, 
          101L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 30L, 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(33L, 10L, 6L, 71L, 18L, 22L, 15L, 57L, 56L, 63L, 35L, 93L, 31L, 43L, 98L, 99L, 62L, 39L, 44L, 86L, 78L, 95L, 6L, 76L, 71L), 12L, 
          32L
      )))
  
  }
  
  main()
source_py: def find_the_missing_number_2(a, n):
      x1 = a[0]
      x2 = 1
      for i in range(1, n):
          x1 = (x1 ^ a[i])
      for i in range(2, (n + 2)):
          x2 = (x2 ^ i)
      return (x1 ^ x2)
source_cpp: int find_the_missing_number_2(vector<int> a, int n) {
    int x1 = a [ 0 ];
    int x2 = 1;
    for ( int i = 1;
    i < n;
    i ++ ) x1 = x1 ^ a [ i ];
    for ( int i = 2;
    i <= n + 1;
    i ++ ) x2 = x2 ^ i;
    return ( x1 ^ x2 );
  }