title: Check If All The Elements Can Be Made Of Same Parity By Inverting Adjacent Elements
signature: check_if_all_the_elements_can_be_made_of_same_parity_by_inverting_adjacent_elements <- 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(1L, 1L, 1L, 7L, 7L, 8L, 10L, 10L, 10L, 14L, 15L, 18L, 20L, 23L, 24L, 24L, 26L, 30L, 32L, 32L, 33L, 36L, 42L, 43L, 46L, 48L, 51L, 51L, 52L, 53L, 58L, 58L, 59L, 59L, 59L, 60L, 67L, 71L, 72L, 74L, 76L, 77L, 83L, 84L, 86L, 90L, 91L), 30L, 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-90L, -20L, -60L, -64L, -24L, 84L, -2L, -32L, 28L, -54L, 44L, -96L, 52L, 88L, 20L, -56L, -2L), 12L, 
          TRUE
      )))
  
      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), 36L, 
          FALSE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(98L, 70L, 24L, 18L, 7L, 4L, 78L, 19L, 70L, 56L, 99L, 54L, 69L, 15L, 88L, 20L, 40L, 13L, 19L, 56L, 62L), 19L, 
          TRUE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-72L, -66L, -58L, -20L, 36L, 80L, 92L), 6L, 
          TRUE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 1L), 1L, 
          TRUE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(6L, 13L, 14L, 16L, 21L, 26L, 26L, 28L, 29L, 35L, 38L, 42L, 47L, 47L, 62L, 67L, 77L, 81L, 81L, 83L, 84L, 88L, 90L, 96L, 97L, 98L), 17L, 
          TRUE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-48L, -8L, 20L, 32L, -90L, -42L, -6L, -88L, -72L, 42L, 66L, -62L, 82L, -4L, 8L, 12L, -22L, 82L, 56L, 96L, -54L, 92L, -42L, 30L, -18L, 14L, -6L, -66L, 34L, 16L, -84L, -94L, 48L, -48L, 52L, -60L, -92L, -16L), 35L, 
          TRUE
      )))
  
      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), 14L, 
          TRUE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(45L, 86L, 53L, 80L, 27L, 45L, 1L, 85L, 91L, 93L, 92L, 43L, 75L, 86L, 81L, 48L, 21L, 34L, 5L, 10L, 88L, 42L, 7L, 15L, 96L, 85L, 62L, 86L, 52L, 37L), 29L, 
          TRUE
      )))
  
  }
  
  main()
source_py: def check_if_all_the_elements_can_be_made_of_same_parity_by_inverting_adjacent_elements(a, n):
      count_odd = 0
      count_even = 0
      for i in range(n):
          if (a[i] & 1):
              count_odd += 1
          else:
              count_even += 1
      if ((count_odd % 2) and (count_even % 2)):
          return False
      else:
          return True
source_cpp: bool check_if_all_the_elements_can_be_made_of_same_parity_by_inverting_adjacent_elements(vector<int> a, int n) {
    int count_odd = 0, count_even = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( a [ i ] & 1 ) count_odd ++;
      else count_even ++;
    }
    if ( count_odd % 2 && count_even % 2 ) return false;
    else return true;
  }