title: Check Possible Sort Array Conditional Swapping Adjacent Allowed
signature: check_possible_sort_array_conditional_swapping_adjacent_allowed <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(1L, 4L, 12L, 16L, 37L, 44L, 47L, 51L, 55L, 57L, 57L, 62L, 62L, 62L, 64L, 69L, 69L, 70L, 72L, 81L, 81L, 88L, 89L, 97L), 15L, 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-86L, 0L, 14L, -16L, -12L, -72L, 62L, -34L, -72L, 30L, 84L, -60L, 84L, -64L, 50L, 74L, 18L, -82L, -64L, -64L, -74L, -56L, 86L, 84L, -32L, -10L, 20L, 4L, 8L, 96L, 82L, 26L, 42L), 18L, 
          FALSE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(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), 31L, 
          TRUE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(48L, 66L, 83L, 12L, 77L, 98L, 18L, 33L, 21L, 16L, 28L, 24L, 46L, 43L), 13L, 
          FALSE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-92L, -58L, -36L, -28L, -6L, 2L, 4L, 26L, 48L, 58L, 60L, 62L, 62L, 98L), 10L, 
          TRUE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 0L, 1L, 0L, 1L), 4L, 
          TRUE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(22L, 38L, 41L, 41L, 42L, 51L, 54L, 58L, 68L, 76L, 80L, 85L), 9L, 
          TRUE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(84L, -38L, 52L, -72L, -24L, 82L, 54L, 74L, 0L), 8L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 1L, 1L), 2L, 
          TRUE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(63L, 31L, 14L, 19L, 77L, 64L, 62L, 23L, 22L, 19L, 39L, 9L, 79L, 1L, 87L, 29L, 58L, 3L, 3L, 39L, 1L, 39L, 35L, 64L, 64L), 13L, 
          FALSE
      )))
  
  }
  
  main()
source_py: def check_possible_sort_array_conditional_swapping_adjacent_allowed(arr, n):
      for i in range(0, (n - 1)):
          if (arr[i] > arr[(i + 1)]):
              if ((arr[i] - arr[(i + 1)]) == 1):
                  (arr[i], arr[(i + 1)]) = (arr[(i + 1)], arr[i])
              else:
                  return False
      return True
source_cpp: bool check_possible_sort_array_conditional_swapping_adjacent_allowed(vector<int> arr, int n) {
    for ( int i = 0;
    i < n - 1;
    i ++ ) {
      if ( arr [ i ] > arr [ i + 1 ] ) {
        if ( arr [ i ] - arr [ i + 1 ] == 1 ) swap ( arr [ i ], arr [ i + 1 ] );
        else return false;
      }
    }
    return true;
  }