Recently, as part of some joint research, Tom Roby was led to a curious operation on strings of L's and R's which he calls "bounce-reading": We start by reading the string at the left. When the symbol we have just read is an L, the next symbol we read is the leftmost unread symbol; but when the symbol we have just read is an R, the next symbol we read is the rightmost unread symbol. For instance, if our string of L's and R's is LLRRLRLR, we read the positions in the order 1,2,3,8,7,4,6,5, obtaining the bounce-reading LLRRLRRL. 


It may be more natural to think of this as an action on circular words; when we read a letter, we delete it, close up the circle, and move either to the left or the right of the deletion-point.


Has this operation been studied before?



an operation on binary strings
Well, it has now, since I just sank my morning into studying it. I sure am a sucker for a naive combinatorics problem. Here's what I know, or can conjecture:


* The map you describe is a bijection on words of length $n$, because it's easy to write down its inverse. I've included python code below.
* Let $B\_L$ be the bounce-reading algorithm. Let $B\_R$ be the bounce-reading algorithm with the following change: replace the phrase "we start by reading the string at the left" with "we start by reading the string at the right". Then $B\_LB\_R^{-1}(w)$ seems to shift $w$ cyclically by one letter. Sometimes the shift is the left, and sometimes to the right; which of these things happens depends on $w$ in a manner which I don't understand. I noticed this because the maximal orbit sizes of $B\_LB\_R^{-1}(w)$ for each $n$ seem to match the OEIS sequence <https://oeis.org/A027375>.
* Let $S\_n$ be the set of words $w$ of length $n$ for which $B\_L(w) = B\_R(w)$. Then the sequence $\{|S\_{n+1}| - |S\_n|\}$ seems to be the Fibonacci numbers, at least for $n\geq 2$. This probably means $S\_n$ has some nice structure.


None of the other obvious statistics that describe this map are in the OEIS yet.


Here are naive python implementations of $B\_L, B\_R, B\_L^{-1}, B\_R^{-1}$ if you want to check these assertions.



```
def bounce_left(w):
    if len(w) == 1:
        return w
    leftchar = w[0]
    x = w[1:]
    if(leftchar == "L"):
        return leftchar + bounce_left(x)
    else:
        return leftchar + bounce_right(x)

def bounce_right(w):
    if len(w) == 1:
        return w
    last_index = len(w) - 1
    rightchar = w[last_index]
    x = w[:last_index]
    if(rightchar == "L"):
        return rightchar + bounce_left(x)
    else:
        return rightchar + bounce_right(x)


def unbounce(w):
    if w == "":
        return ""
    output = ""
    n = len(w) - 1
    for index in reversed(range(n)):
        if w[index] == "L":
            output = w[index+1] + output
        else:
            output = output + w[index+1]
    return output

def unbounce_left(w):
    return unbounce("L" + w) 

def unbounce_right(w):
    return unbounce("R" + w)

```

