title: Check Whether Arithmetic Progression Can Formed Given Array
signature: check_whether_arithmetic_progression_can_formed_given_array <- 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, 16L, 64L), 4L, 
          FALSE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(0L, 4L, 8L, 12L), 4L, 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(-2L, 0L, 2L, 4L, 6L), 5L, 
          TRUE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), 7L, 
          TRUE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(46L, 56L, 66L, 76L, 86L), 5L, 
          TRUE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(46L, 56L, 56L, 66L, 76L, 86L), 6L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(7L, 9L, 11L, 21L, 44L, 45L, 61L, 67L, 78L, 97L, 98L, 99L), 11L, 
          FALSE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-96L, -84L, -74L, -70L, -68L, -62L, -50L, -50L, -38L, -36L, -36L, -36L, -34L, -34L, -28L, -28L, -26L, -18L, -12L, -4L, -4L, -2L, -2L, 6L, 6L, 14L, 24L, 34L, 36L, 44L, 50L, 54L, 54L, 62L, 64L, 66L, 70L, 74L, 74L, 78L, 84L, 86L), 33L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 33L, 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(1L, 3L, 5L, 11L, 14L, 15L, 15L, 17L, 18L, 19L, 20L, 20L, 22L, 32L, 33L, 35L, 36L, 37L, 39L, 44L, 45L, 46L, 51L, 54L, 57L, 58L, 61L, 61L, 63L, 64L, 67L, 69L, 70L, 70L, 79L, 82L, 86L, 89L, 92L, 93L, 95L, 99L), 40L, 
          FALSE
      )))
  
  }
  
  main()
source_py: def check_whether_arithmetic_progression_can_formed_given_array(arr, n):
      if (n == 1):
          return True
      arr.sort()
      d = (arr[1] - arr[0])
      for i in range(2, n):
          if ((arr[i] - arr[(i - 1)]) != d):
              return False
      return True
source_cpp: bool check_whether_arithmetic_progression_can_formed_given_array(vector<int> arr, int n) {
    if ( n == 1 ) return true;
    sort(arr.begin(), arr.end());
    int d = arr [ 1 ] - arr [ 0 ];
    for ( int i = 2;
    i < n;
    i ++ ) if ( arr [ i ] - arr [ i - 1 ] != d ) return false;
    return true;
  }