title: Check String Follows Anbn Pattern Not
signature: check_string_follows_anbn_pattern_not <- function(str) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(str, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(str), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          "ba", 
          FALSE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          "aabb", 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          "abab", 
          FALSE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          "aaabb", 
          FALSE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          "aabbb", 
          FALSE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          "abaabbaa", 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          "abaababb", 
          FALSE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          "bbaa", 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          "11001000", 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          "ZWXv te", 
          FALSE
      )))
  
  }
  
  main()
source_py: def check_string_follows_anbn_pattern_not(str):
      n = len(str)
      for i in range(n):
          if (str[i] != 'a'):
              break
      if ((i * 2) != n):
          return False
      for j in range(i, n):
          if (str[j] != 'b'):
              return False
      return True
source_cpp: bool check_string_follows_anbn_pattern_not(string str) {
    int n = str . length ( );
    int i;
    for ( i = 0;
    i < n;
    i ++ ) if ( str [ i ] != 'a' ) break;
    if ( i * 2 != n ) return false;
    int j;
    for ( j = i;
    j < n;
    j ++ ) if ( str [ j ] != 'b' ) return false;
    return true;
  }