The aim of this challenge is to write a program that satisfies the following conditions:
The program is not palindromic, or essentially palindromic (meaning that it is possible to remove characters to make it a palindrome without changing the effects of the program).
The program is not an involution (meaning that it does not produce its original input when run on its output)
The reversed-polarity program is the inverse of the normal program; so when the reversed program is run on the output of the normal program, it returns the original input.
What does reversed-polarity mean? Well, it differs between languages.
- For most non-esolangs, this means reversing the order of sub-operations in a single operation, reversing the order of arguments, and reversing the contents of hard-coded lists/arrays/tuples/dictionaries/stacks/queues/etc, as well as reversing the order of code-blocks and stand-alone lines (but not lines within blocks)
Examples:
Haskell:
x`mod`y
-> y`mod`x
;zipWith ((*3).(+)) [1,2,3] [4,5,6]
-> zipWith ((+).(*3)) [6,5,4] [3,2,1]
Python: 2**3
-> 3**2
; for x,y in [(1,2),(3,4),(5,6)]
-> for y,x in [(6,5),(4,3),(2,1)]
For languages that have 1-character functions (like Pyth, APL), simply reverse the string of instructions
For 1-dimensional esolangs like BF, reverse the instructions or swap the polarity; polarity swaps are
[]
->{}
,+
->-
,-
->+
,>
-><
,<
->>
,.
->,
and,
->.
(but not both)For 2-dimensional esolangs like Befunge, you may either perform a reflection across the x- or y- axes or a diagonal, rotate 180 degrees, or do a combination of a reflection and a rotation
Commutative operations are allowed, but palindromic ones are not: 2*x
is fine, but x+x
is bad. The definition of a polarity-reversal is pretty loose, but use your judgment as to what makes sense; the object isn't to find the most clever loophole, but to find the most clever solution.
This is a popularity contest, so a very clever loophole may be popular, but try to keep within the spirit of this challenge. The winner will be announced once there are at least 10 solutions with at least 1 upvote, and there is at least one solution with more upvotes than there are submissions with at least 1 upvote; or in 1 month, whichever comes first. This is my first challenge, so try to be fair and give me constructive feedback, but also let me know if this is an unreasonable challenge or it is in any way miscategorized or ambiguous. If you have questions about a language that don't fit into any of the pigeonholes I have set out here, comment, and I will bend to the will of the community if there is a strong outcry for a particular clarification or rule-change.
UPDATE
It has been exactly 1 month since this contest was started (I just happened to check on it by chance, not knowing that I was actually on time). As this is a popularity contest, the winner (by a landslide) is Pietu1998-Befunge. Even though the bottom components (the text reverser and the backwards-alphabet) are both involutions, the encoder/decoder are not, so there is no problem there. Bonus points (in my mind) for managing to write "BEFUNGE" down the middle. I personally liked the novelty of Zgarb's Theseus solution, because the language looks cool (if restricted). Thanks to everyone for participating, and while the winner has been chosen, I am leaving this contest completely open, and welcome future submissions.
()
palindromic? Technically, the reverse is)(
. \$\endgroup\$