ROT13 and upside-down text (flip text)

2

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.

James Webster

Posted 2017-06-08T09:34:02.670

Reputation: 2 809

3Please include a list of the flipped alphabet. – Leaky Nun – 2017-06-08T09:38:49.550

related – Leaky Nun – 2017-06-08T09:40:12.340

@EriktheOutgolfer, I think it's probably different enough for a few reasons. I've added my reasons to the question. – James Webster – 2017-06-08T10:24:06.663

@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? – Erik the Outgolfer – 2017-06-08T10:28:53.313

The limit is mentioned in the question: The flipped alphabet can be anything visually similar to the flipped lowercase Latin alphabet so long as it can be accepted as input. I've clarified the output as input section, however. By graphical solution, I understand that Mathemetica would be to rotate text rather than replace characters. – James Webster – 2017-06-08T10:34:28.423

There is the opportunity for graphical solutions in this question.: I don't see how unless you are performing some OCR. – TheLethalCoder – 2017-06-08T10:37:09.867

6Your 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. – Neil – 2017-06-08T10:44:53.530

Your upside-down q is a b. – Magic Octopus Urn – 2017-06-08T14:44:20.300

Answers

1

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!

Uriel

Posted 2017-06-08T09:34:02.670

Reputation: 11 708

@JonathanAllan fixed (plus space issue). in case of ambiguity (like "uodb") will choose the normal alphabet to translate from – Uriel – 2017-06-09T03:34:21.130

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? – Jonathan Allan – 2017-06-09T03:43:20.217

@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. – Uriel – 2017-06-09T03:47:43.547

@JonathanAllan I can't see dennis' tio links (wifi provider blocks) – Uriel – 2017-06-09T04:03:34.040

Wow, why? OK lambda s,a='abcdefghijklmnopqrstuvwxyz υοďƄɹ5ʇηʌʍXʎ2ɐʠɔǷəɟɓɥ!ɾʞ|ɯ ':''.join(a[(a.find(c)+27)%54]for c in s) – Jonathan Allan – 2017-06-09T04:05:09.333

@JonathanAllan wish I knew. nice use for Ƅ Ƿ and |. I think the last one can use the integral sign, and does not need to be replaced by !. – Uriel – 2017-06-09T04:08:11.727

Let us continue this discussion in chat.

– Jonathan Allan – 2017-06-09T04:08:30.240

1

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)&

J42161217

Posted 2017-06-08T09:34:02.670

Reputation: 15 931