TL;DR: 3rd-order Hilbert curve. Uses character input, looping until a newline is given. Sums up the values (96 (5*3+9*9) minus them), and in the end adds 100 (5*5*4) and checks whether it's zero. Uses the fairly new catch marks.
}){(
(o-+
d{))
|(&
=,d@*45(
{d""*+5(
3*)+=0
599*p
Outputs True
if the given word is a dollar word, False
otherwise.
Explanation:
We first construct a 96 by calculating 5*3+9*9: 53*99*+
. Next, we move a stack to the right and push an empty string: )""
. Because we're about to enter a repeating part, we set the catching mark using @
. This is where we will return if an error occurs.
We d
uplicate the empty string, read a single character (,
), d
uplicate that character, and move it to the original stack ({
). Still on the right stack, we compare the top two values (the empty string and our character) and use the conditional mirror to jump to the right edge if they are equal: =|
.
Assuming they're not, we now move on the left stack, push the character once more one stack to the left, duplicate the 96, go to the left stack, push the character back on the middle stack and go there again: ({d(})
.
Now we convert the character to the value of its unicode codepoint and subtract it from 96, resulting in it's negated dollar value: o-
. We do it this way, because we'd have to swap the values otherwise. We push the value to the left stack, go there, and add the two values there (initially 0 and our negative character value): {(+
. To prepare for reading another character, we go to the middle stack again )
, and then raise an error: &
.
Once a newline is read and the character is therefore empty and the equality truthful, we got mirrored somewhere on the top-left quadrant; the exact position doesn't matter in our case. The next operation that does something is moving back on the stack of our final value: ((
. On it, we should now have the sum of all character values, negative. That means, if it's a dollar word, it should be -100. To test whether it is, we add 100 (554**+
), push 0
, test for equality and print the result: =p
.