4
\$\begingroup\$

This question already has an answer here:

Turn the characters abcdefghijklmnopqrstuvwxyz!?., upside down and don't modify the other characters. Then, reverse the text to achieve the upside down affect. If text is already upside down, turn it right side up. Don't modify capitals.

Use this as a reference:

abcdefghijklmnopqrstuvwxyz!?.,
ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz¡¿˙'

Rules

  • Newlines must be supported
  • You only have to convert the above character set.
  • Don't forget you need to reverse the characters.
  • This question is symmetrical unlike Small Caps Converter.

Test cases

42 is the meaning of life -> ǝɟıן ɟo ƃuıuɐǝɯ ǝɥʇ sı 24
halp why is my keyboard typing upside down??? :( -> (: ¿¿¿uʍop ǝpısdn ƃuıdʎʇ pɹɐoqʎǝʞ ʎɯ sı ʎɥʍ dןɐɥ
lol -> ןoן
uoɥʇʎpʎzɐɹc -> ɔrazydython

Look at my username!

\$\endgroup\$

marked as duplicate by Blue, DJMcMayhem, Rɪᴋᴇʀ, FryAmTheEggman, Peter Taylor code-golf Jun 13 '16 at 21:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3
\$\begingroup\$

Ruby, 78 bytes

I need to use an actual byte counter more often

->s{s.reverse.tr'a-z!?.,',"ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz¡¿˙'"}

Try it online

\$\endgroup\$
  • \$\begingroup\$ Very nice indeed! \$\endgroup\$ – Leaky Nun Jun 13 '16 at 17:56
  • \$\begingroup\$ It would be 78 bytes, lol. 2D 3E 73 7B 73 2E 72 65 76 65 72 73 65 2E 74 72 27 61 2D 7A 21 3F 2E 2C 27 2C 22 C9 90 71 C9 94 70 C7 9D C9 9F C6 83 C9 A5 C4 B1 C9 BE CA 9E D7 9F C9 AF 75 6F 64 62 C9 B9 73 CA 87 6E CA 8C CA 8D 78 CA 8E 7A C2 A1 C2 BF CB 99 27 22 7D \$\endgroup\$ – Leaky Nun Jun 13 '16 at 18:01
  • \$\begingroup\$ @Adnan, fixed the byte count \$\endgroup\$ – Value Ink Jun 13 '16 at 18:13
  • \$\begingroup\$ @KevinLau-notKenny, was the problem characters vs bytes? \$\endgroup\$ – Solomon Ucko Jun 13 '16 at 21:22
  • \$\begingroup\$ @SolomonUcko if you're talking about my comment about needing to use a byte counter, yes. This had 59 characters which tied with Pyth's byte count, so I was bragging about tying with Pyth even though my bytecount wasn't actually the same \$\endgroup\$ – Value Ink Jun 14 '16 at 4:57
3
\$\begingroup\$

Retina, 73 bytes (54 chars)

Translate the chars, then reverse the input. I was pretty confused while making this until I realized some of the chars need to be escaped.

T`ɐqɔ\pǝɟƃɥıɾʞןɯu\o\dbɹsʇnʌʍxʎz¡¿˙'l!?.,`l!?.,o
O$^s`.

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Pyth, 59 bytes

X_z+G"!?.,'˙¿¡zʎxʍʌnʇsɹbdouɯןʞɾıɥƃɟǝpɔqɐ

Test suite.

Obligatory hexdump:

58 5F 7A 2B 47 22 21 3F 2E 2C 27 CB 99 C2 BF C2
A1 7A CA 8E 78 CA 8D CA 8C 6E CA 87 73 C9 B9 62
64 6F 75 C9 AF D7 9F CA 9E C9 BE C4 B1 C9 A5 C6
83 C9 9F C7 9D 70 C9 94 71 C9 90
\$\endgroup\$
  • \$\begingroup\$ That was golfed quite a bit. \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Jun 13 '16 at 17:36
  • \$\begingroup\$ Damn and I thought I was in with a chance when this first landed :P \$\endgroup\$ – Dom Hastings Jun 13 '16 at 17:37
  • \$\begingroup\$ Yeah, it was embarrassing. \$\endgroup\$ – Leaky Nun Jun 13 '16 at 17:39
  • 1
    \$\begingroup\$ @LeakyNun ok. wonder why unicode does this \$\endgroup\$ – Maltysen Jun 13 '16 at 17:51
  • 1
    \$\begingroup\$ @Maltysen z, x, s, o are preserved; n and u are swapped; b and q are swapped; d and p are swapped; inverted y, w, v belong to IPA, and stuff. \$\endgroup\$ – Leaky Nun Jun 13 '16 at 17:54
2
\$\begingroup\$

Python 3, 144 bytes

Don't work in the Windows terminal...

print(''.join([dict(zip("abcdefghijklmnopqrstuvwxyz!?.,","ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz¡¿˙'")).get(x,x)for x in input()[::-1]]))
\$\endgroup\$
  • \$\begingroup\$ This can be heavily golfed. \$\endgroup\$ – Leaky Nun Jun 13 '16 at 17:54
  • \$\begingroup\$ @LeakyNun I know, the vars were for debugging purpose... \$\endgroup\$ – TuxCrafting Jun 13 '16 at 17:55
  • \$\begingroup\$ Then you can remove them now. reversed can be replaced by [::-1]. Converting it to a lambda may save some bytes. \$\endgroup\$ – Leaky Nun Jun 13 '16 at 17:56
  • \$\begingroup\$ @LeakyNun Thank you ! \$\endgroup\$ – TuxCrafting Jun 13 '16 at 17:57
  • \$\begingroup\$ @KevinLau-notKenny It's for python 2 or 3 ? Because on my python 3 installation it throw a error \$\endgroup\$ – TuxCrafting Jun 13 '16 at 18:17
2
\$\begingroup\$

JavaScript (ES6), 140 bytes

f=
s=>[...s].map(c=>r=((i=u.indexOf(c)+26)<26?c:u[i%52])+r,r="",u="abcdefghijklmnpqrtuvwy!?.,ɐqɔpǝɟƃɥıɾʞןɯudbɹʇnʌʍʎ¡¿˙'")&&r
;
<input oninput=o.value=f(this.value)><input id=o style=text-align:right>

Edit: Saved 8 bytes thanks to @Dúthomhas.

\$\endgroup\$
1
\$\begingroup\$

Perl, 88 bytes

78 bytes code + 10 for -Mutf8 -n

y/a-z!?.,/ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz¡¿˙'/;print reverse/./g

Usage

Save as upsidedown.pl and run:

perl -Mutf8 -n upsidedown.pl <<< '42 is the meaning of life'
ǝɟıן ɟo ƃuıuɐǝɯ ǝɥʇ sı 24
\$\endgroup\$

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