title: Check String Follows Anbn Pattern Not
signature: function checkStringFollowsAnbnPatternNot($str) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($str, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($str), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        "ba", 
        false));
      
      printf("TEST-1...%s\n",driver(
        "aabb", 
        true));
      
      printf("TEST-2...%s\n",driver(
        "abab", 
        false));
      
      printf("TEST-3...%s\n",driver(
        "aaabb", 
        false));
      
      printf("TEST-4...%s\n",driver(
        "aabbb", 
        false));
      
      printf("TEST-5...%s\n",driver(
        "abaabbaa", 
        false));
      
      printf("TEST-6...%s\n",driver(
        "abaababb", 
        false));
      
      printf("TEST-7...%s\n",driver(
        "bbaa", 
        false));
      
      printf("TEST-8...%s\n",driver(
        "11001000", 
        false));
      
      printf("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;
  }