Code Golf string decision-problem
A small variation of [a challenge on CGCC.SE](https://codegolf.stackexchange.com/q/85994/78410).

## Task

Given a string $s$ made of only lowercase a's and b's, determine if it satisfies

s \in \{ a^n b^n a^n | n \in \mathbb{Z}, n \ge 0 \}

In plain English, determine if $s$ equals some (possibly zero) copies of `a`, followed by the same number of `b`, followed by the same number of `a`.

## Input and output

A full program or a function is acceptable.

You can take input as a string, a list of characters, or a list of codepoints (which will then be a list of 97 and 98).

You can choose to output one of the following:

* Truthy / falsy values following your language's convention (swapping is also allowed)
* Two distinct values representing true / false respectively

## Test cases

| Input | Output |
| :-- | :-: |
| ` ` (empty string) | true |
| `aba` | true |
| `aabbaa` | true |
| `aaabbbaaa` | true |
| `a` | false |
| `b` | false |
| `ab` | false |
| `ba` | false |
| `aab` | false |
| `aabbaab` | false |
| `aabbaaa` | false |
| `aaabbaa` | false |
| `baabbaa` | false |
| `aabbbaa` | false |
Top Answer
# [APL (Dyalog Unicode)], 17 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")^SBCS^
Anonymous tacit prefix function. Requires 0-based indexing (`⎕IO←0`)
[Try it online!][TIO-k60fj353]

| Reading order| Notes
| ---- | -----
| `⊂∊` |Is the whole argument a member of
|   `'aba'/¨∘⊂`|the whole of "aba", with its letters replicated by each
|            `∘`  | of
|             `⍳`  | 0, 1, …
|              `1⌈` | the maximum of 1 and
|               `≢`  | the tally of characters?

| Execution order| Notes
| ---- | -----
|               `≢`  | tally the argument
|              `1⌈` | the maximum of 1 and that
|             `⍳`  | 0, 1, … that
|            `∘`  | then
|   `'aba'/¨∘⊂`|For each of those, replicate the characters of "aba"
| `⊂∊` |is the whole argument a member of that list?

[APL (Dyalog Unicode)]: https://www.dyalog.com/
[TIO-k60fj353]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/x91NT3q6FJPTEpU1z@04lHHDJBAL5jRu9nwUU/Ho85F/9OASh/19kF0dTUfWm/8qG0ikBcc5AwkQzw8g/@nqatzpYGNAVGJSUmJUBaQCWRDOCAiCaIOzIQpRuhBYiL0Q5hJyKaCDVUHAA "APL (Dyalog Unicode) – Try It Online"
Answer #2
# [Golfscript](http://www.golfscript.com/), 26 bytes


Not particularly optimal, but the first solution I thought of. Probably could pare down the string-comparison bit into some kind of bitwise comparison. ~++"aba"= is 9 bytes just to check "is the order right", when it could probably be done in 3 somehow. After the loop, we would have (if correct), ["a", "b", "a"], so it should be doable. I'll check some bitwise comparisons later, but this is a good starting benchmark.


..  #Duplicate the string twice. Stack is now three copies.
  3/  #Divide the string into parts of size 3.
    ,  #Count how many parts there are, and get rid of that copy
     /  #Divide one of the two original strings into three parts
     	#using the prev number
      {.|}/  #For each of these parts, get rid of duplicates
           ~++  #Break them out of the array then concatenate them.
              "aba"=  #Make sure the array followed the pattern of
              		  #1/3 a's, 1/3 b's, then 1/3 a's again.
                      #If so, we replace it with 1. Otherwise 0.
                    \  #Bring that last original-string over.
                     ,3%  #Make sure it's a clean multiple of three.
                        !  #If so, 1. If not, 0.
                         *  #Multiply! 1*1=1, and 0*1 or 0*0=0, so if
                            #both conditions pass, we pass 1.
Answer #3
## [Haskell], 26 bytes

f s=[c|c<-"aba",'b'<-s]==s

[Try it online!][TIO-k61uvjuc]

[Haskell]: https://www.haskell.org/
[TIO-k61uvjuc]: https://tio.run/##TYxBCoAwDAS/EoLgxf7AvkQ8JMWqWKUYj77dWK2il2QWZncgmboQVD2IbdzuaoPEhFXJZW2ktVZ0pnEBC3Edlw0KmCmChwaxgqymR8z0UMLEOVyHs3fjK3@dH379jPxfvUex1cP5QL2ocTGe "Haskell – Try It Online"

Checks that the input string is equivalent to the following construction: for each character in `"aba"`, repeat that character once for each `'b'` in the input (checked with the pattern match `'b'<-s`).

An equally-long alternative uses `<*`.

f s=("aba"<*[1|'b'<-s])==s

[Try it online!][TIO-k61v36zg]

[Haskell]: https://www.haskell.org/
[TIO-k61v36zg]: https://tio.run/##TYxLCoRADESvEoLgB124t08iLhKZVrGVZuLSsxu1ewbdJK/gVY0k88c5VQtiMiQmbIq23lNOm0q63BjRhaYVDPjvtG6QwEIeLLSIJQT/fsRMP7rw4hjuw9EL@JefzguffkR@r4ZR7PToraNBtOq9PwE "Haskell – Try It Online"
Some a's, b's, and then a's
Bubbler replying to Wheat Wizard
Yeah, even in Python `'abc'` and `['a','b','c']` are two different things. Probably a better term could be *sequence of chars*.
Wheat Wizard
Not all languages implement strings that way.  Prolog is one of them.
I'll edit to explicitly allow list of chars and list of codepoints.
Bubbler replying to Wheat Wizard
Well, a string *is* just a list of characters.
Wheat Wizard
Personally I want to answer this in Prolog, so list of codepoints would be leagues better than strings.  But from a more impartial standpoint I don't see why strings are used as opposed to lists, since the structure in question is really a list.
Bubbler replying to Wheat Wizard
Would it be fine to allow a list of codepoints (that is, a list of 97 and 98) but not a list of e.g. 1 and 2? Or do you want any list of two distinct integers?
Wheat Wizard
@Bubbler Could we use a list of integers instead of a string?  Strings seem like a bit of a complex type to me.