MathOverflow will be down for maintenance for approximately 3 hours, starting Monday evening (06/24/2013) at approximately 9:00 PM Eastern time (UTC-4).

3 grammar. sheesh.

Well, it has now, since I just sunk 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$ are given by 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)

2 second attempt at clarification.

Well, it has now, since I just sunk 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 map you describe, and bounce-reading algorithm. Let $B_R$ be the bounce-reading starting at algorithm with the right instead of 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$ are given by 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)

1

Well, it has now, since I just sunk 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 map you describe, and $B_R$ be bounce-reading starting at the right instead of the left. 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$ are given by 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)