2
\$\begingroup\$

When I saw this title in the Hot Network Questions I thought it was going to be a PPCG challenge. I was a little disappointed when it was on Mathematica.

So now it is on PPCG:

Challenge

Given an input string, output the ROT13, flipped value. The input will contain characters from the following alphabet: [abcdefghijklmnopqrstuvwxyz <flipped alphabet>]1

The flipped alphabet can be anything visually similar to the flipped lowercase Latin alphabet so long as it can be accepted as input.

The space character should remain unchanged.

As an example, your flipped alphabet might be zʎxʍʌnʇsɹbdouɯlʞɾᴉɥƃɟǝpɔqɐ

Example

Input:    caesar woz ere
Rot13:    pnrfne jbm rer
Output:   ɹǝɹ ɯqɾ ǝuɟɹud

Input:    ɹǝɹ ɯqɾ ǝuɟɹud
Rot13:    pnrfne jbm rer
Output:   caesar woz ere

Scoring

Simple , the lowest number of bytes wins.


I think this is different enough to the proposed duplicate for a few reasons:

  • The answerer has the choice of which characters to use as output (within limits)
  • The process should be reversible. i.e. flipped text should be acceptable as input and return "normal" text.
  • There is the opportunity for graphical solutions in this question.
\$\endgroup\$
  • 3
    \$\begingroup\$ Please include a list of the flipped alphabet. \$\endgroup\$ – Leaky Nun Jun 8 '17 at 9:38
  • \$\begingroup\$ related \$\endgroup\$ – Leaky Nun Jun 8 '17 at 9:40
  • \$\begingroup\$ @EriktheOutgolfer, I think it's probably different enough for a few reasons. I've added my reasons to the question. \$\endgroup\$ – James Webster Jun 8 '17 at 10:24
  • \$\begingroup\$ @JamesWebster Then, first of all, what are the limits? Second, what do you mean by "graphical solutions"? If the output is an image, are the solutions below supposed to take that image as input and print the original text or something? \$\endgroup\$ – Erik the Outgolfer Jun 8 '17 at 10:28
  • 6
    \$\begingroup\$ Your flipped alphabet contains letters from the roman alphabet, so it's impossible to know whether d is a flipped p and should therefore rot13 to ɔ before flipping to c, rather than rot13 to q and flipping to b. \$\endgroup\$ – Neil Jun 8 '17 at 10:44
1
\$\begingroup\$

Mathematica, 234 bytes

T=ToExpression;B=Characters;L=T@CharacterRange["a","z"];K=T@B@"uodbɹsʇnʌʍxʎzɐqɔpǝɟƃɥᴉɾʞlɯ";(If[Max@ToCharacterCode@#<123,A=L;F=K,A=K;F=L];S=Association@Table[ToRules[A[[Z]]==F[[Z]]],{Z,Length@L}];Row@Reverse@T@B@#/.S)&
\$\endgroup\$
1
\$\begingroup\$

Python 3, 120 bytes

many bytes saved thanks to @JonathanAllan

lambda s,a='abcdefghijklmnopqrstuvwxyz VOďƄɹ5ʇη^MXʎ2ɐʠ>Pəɟ6ɥ!ɾʞ|W ':''.join(a[(a.find(c)+27)%54]for c in s)

Try it online!

\$\endgroup\$
  • \$\begingroup\$ @JonathanAllan fixed (plus space issue). in case of ambiguity (like "uodb") will choose the normal alphabet to translate from \$\endgroup\$ – Uriel Jun 9 '17 at 3:34
  • \$\begingroup\$ Nice fix, although the [abc... <flipped>] does suggest one alphabet and possible mixed input, maybe you can save bytes and fix both at the same time by picking some other unicode chars? \$\endgroup\$ – Jonathan Allan Jun 9 '17 at 3:43
  • \$\begingroup\$ @JonathanAllan I already tested the option to use a single string (with a[(a.index(x)+27)%54], but I didn't find decent replacements for the overlapping characters. \$\endgroup\$ – Uriel Jun 9 '17 at 3:47
  • \$\begingroup\$ @JonathanAllan I can't see dennis' tio links (wifi provider blocks) \$\endgroup\$ – Uriel Jun 9 '17 at 4:03
  • \$\begingroup\$ Wow, why? OK lambda s,a='abcdefghijklmnopqrstuvwxyz υοďƄɹ5ʇηʌʍXʎ2ɐʠɔǷəɟɓɥ!ɾʞ|ɯ ':''.join(a[(a.find(c)+27)%54]for c in s) \$\endgroup\$ – Jonathan Allan Jun 9 '17 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.