Background
Stack Cats is a reversible esoteric language made by Martin Ender. Each command in Stack Cats is either the inverse of itself (represented as a symmetric character, such as -_:T|
), or has its inverse command (represented as the mirror image, such as ()
{}
[]
<>
). Stack Cats has a strong syntactic requirement that the whole program should be the mirror image of itself. Note that this means any valid Stack Cats program is a natural mirror-image ambigram.
Here is the whole command set of Stack Cats:
- Self-symmetric:
!*+-:=ITX^_|
- Symmetric pairs:
()
{}
[]
<>
\/
Any other characters are invalid; any input having a character not in the character set above should output false.
The language has additional constraint that ()
and {}
pairs must be always balanced, but for the sake of simplicity, you don't have to check for this condition.
The following are some examples of a valid Stack Cats program (again, note that you don't check for balanced parens):
{[+]==[+]}
[)>^<(]
({T)}|{(T})
<(*]{[:!-_:>}<[<)*(>]>{<:_-!:]}[*)>
These are not:
b<+>d
())(
({[<++<]})
Challenge
Write a program or function that determines if the given string is a valid Stack Cats program. Your code should also be a natural mirror-image ambigram, which means:
- Your code should be a mirror image of itself.
- Your code may have one or more newlines, as long as the whole code, displayed naturally, is a mirror image of itself.
- You can omit or add trailing whitespaces on each line, since it doesn't change the display.
- Tab characters are not allowed since they have some ambiguity on display.
Note: your code does not have to be a valid Stack Cats program; it may contain certain extra characters that are not allowed in Stack Cats. (See below for the complete list.)
For example, the following two programs are symmetric (and thus a valid submission), while the third is not:
({bTd})
[<q|p>]
({bTd})
IXI
({bTd})
IXI
- Regarding "mirror symmetry", only Stack Cats-style vertical symmetry is considered (e.g.
({IH})
is not a valid submission, even though it has horizontal mirror symmetry). - Your code can only contain these sets of characters, plus newline:
- Self-symmetric: space (
0x20
) +!"'*+-.8:=AHIMOTUVWXY^_ovwx|
- Symmetric pairs:
()
/\
<>
[]
bd
pq
{}
- Self-symmetric: space (
The character set is chosen to be strictly symmetric or self-symmetric when displayed as code on SE.
Input and Output
The input range is any one-line string of printable ASCII characters.
You can choose to take input as a string, a list of chars, or a list of ASCII values.
You can choose to output either:
- Any of the truthy/falsy values as defined by the language of your choice
- The actual result values may differ between inputs (e.g. output 1 for a truthy input and 2 for another truthy one).
- Swapping truthy and falsy values is not allowed.
- Any two constant values for true/false respectively
- In this case, the result values should exactly be one of the two constant values.
You should specify your input method and output values in your submission.
Winning Condition
This is code-golf, so lowest bytes in each language wins.
Notes
- Standard loopholes are forbidden as usual.
- Of course you can solve this in Stack Cats, but the catch is that you can't use a flag that allows you to reduce your code size by half. And it's a seriously hard language to pick up. :P
#
disallowed? \$\endgroup\$