r/codegolf • u/LT_Wobbles • Jun 01 '14
[perl] Reversible Substitution Algorithm
I propose a new challenge.
write a program in the shorted amount of characters which:
- Takes an input string
- Performs 3 different substitution on the string (swapping every two characters, reversing the string, replacing all characters with equivalent hex values, etc, be creative)
- Perform a 1/2 rotation substitution. Essentially each letter maps to the 13 letter over in the alphabet
- The algorithm must be reversible. Meaning I enter a string like "hello" and get some nonsense like "ryubb", and when I make "ryubb" the input I should get "hello".
1
Upvotes
View all comments
Show parent comment
2
u/zifyoip Jun 01 '14
Hmm. On second thought, it might not be that difficult—you just need to find a set of involutions that commute under composition. So you could use ROT-13, case-flipping, reversing the string, and swapping the first and last characters of the string, for example:
Of course, that hasn't been codegolfed.