title: Check String Follows Anbn Pattern Not
signature: function check_string_follows_anbn_pattern_not(str)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(str, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(str), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver("ba", false);
      @printf("TEST-0...%s\n",result);
      
      result = driver("aabb", true);
      @printf("TEST-1...%s\n",result);
      
      result = driver("abab", false);
      @printf("TEST-2...%s\n",result);
      
      result = driver("aaabb", false);
      @printf("TEST-3...%s\n",result);
      
      result = driver("aabbb", false);
      @printf("TEST-4...%s\n",result);
      
      result = driver("abaabbaa", false);
      @printf("TEST-5...%s\n",result);
      
      result = driver("abaababb", false);
      @printf("TEST-6...%s\n",result);
      
      result = driver("bbaa", false);
      @printf("TEST-7...%s\n",result);
      
      result = driver("11001000", false);
      @printf("TEST-8...%s\n",result);
      
      result = driver("ZWXv te", false);
      @printf("TEST-9...%s\n",result);
      
  end
  
  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;
  }