Python 100% using formula
Assume there will always be more b than a.\nThen the result string would be like the following form - (bb)(abb)(abb)(abb)...(ab)(ab)(ab).\n\nIn conclusion there
Assume there will always be more `b` than `a`.\nThen the result string would be like the following form - `(bb)(abb)(abb)(abb)...(ab)(ab)(ab)`.\n\nIn conclusion there will be  three patterns:\n* `bb` - could only appear in the most front of the result string\n* `abb` - assume there are `x` sets of this string (`x>=0`)\n* `ab` - assume there are `y` sets of this string (`y>=0`)\n\nWe could calculate the exact values of `x` and `y`, by listing following linear equations:\n* x + y = a (`a` is equal to the sum of `x` and `y`)\n* 2x + y = b (`b` is equal to the sum of `2x` and `y`, because `b` exists twice in string `x`)\n\nResulting in the final formula:\n* x = b - a\n* y = 2a - b\n\nThen we go to handle the edge case when `bb` is needed in the most front of the string.\nLet\'s say, `a=1, b=4`. Then according to the devised formular `x=3, y=-2`. The negative value of `y` contradicts our basic assumption `y>=0`. (This contradiction means we will need `-2` sets of string `y`(`ab`), which obviously contradicts to the reality.)\nIn conclusion, whevever the values of `x` or `y` are negative, we need to put a set of `bb` in the most front.\n\nSo below is the complete code.\n\n```\ndef strWithout3a3b(self, A, B):\n\t(a, str_a), (b, str_b) = sorted([(A, \'a\'), (B, \'b\')])\n\n\tfront_b = False\n\tif 2*a < b:\n\t\tb -= 2\n\t\tfront_b = True\n\tx = b - a\n\ty = 2*a - b\n\n\tstr_x = str_a + str_b + str_b\n\tstr_y = str_a + str_b\n\tstr_front = (str_b * 2) if (front_b) else \'\'\n\treturn (str_front) + (str_x * x) + (str_y * y)\n```
[]