Bacon's cipher is a classic steganographic method, but to decode it, you need to know which symbol is A, which symbol is B and which direction to read them in. (That said, you could just try all the possibilities, and all but one would likely come out as gibberish.) But what if you wanted a code that worked unambiguously without needing to identify which is the A symbol and which is the B symbol?
How long would a fixed length code need to be to encode a 26 character alphabet if -
- codewords can't collide when the symbols are inverted? (That is, if ABAAB is a codeword, BABBA isn't. Alternatively, ABAAB and BABBA could encode the same character.)
- codewords can't collide when read backwards or when the symbols are inverted? (That is, if ABAAB is a codeword, none of BAABA, BABBA or ABBAB are.)
- codewords can't collide if placed on an n-by-n grid and the grid is transposed or the symbols are inverted?
- codewords can't collide if placed on an n-by-n grid and read sideways, backwards, transposed, inverted, etc.?
For an example for the second two, assume ABAAB and ABBBB are a codewords, then they could be put in to a 5-by-5 grid:
ABAAB
ABBBB
ABAAB
ABBBB
ABBBB
This grid could either be read left-to-right then top-to-bottom or top-to-bottom then left-to-right in the third question (and the symbols might or might not be inverted). The codewords must be such that every combination of valid codewords in one direction will create at least one invalid codeword in the other direction so that someone with the codebook can definitely tell how it should be read. For example, perhaps ABABB isn't a valid codeword. (If this holds true for an n-by-n grid, then it should also hold true for an xn-by-yn grid.)
The same is true for the fourth question, but the correct direction could be any of the eight possibilities. The alternate interpretation where colliding codewords represent the same character doesn't really make sense for these questions.
I believe that if it were required that no valid codewords appeared in the other directions, both the last two questions would be impossible, but it'd be more interesting if I were wrong about that.
(Note: I don't have a definite answer to the last two of these.)