Skip to content

Instantly share code, notes, and snippets.

@frankrolf
Last active September 3, 2020 11:09
Show Gist options
  • Save frankrolf/16108a30841d848fd41f5264a8200abc to your computer and use it in GitHub Desktop.
Save frankrolf/16108a30841d848fd41f5264a8200abc to your computer and use it in GitHub Desktop.
Table-flip any phrase you like! (╯°□°)╯︵ ǝsɐɹɥd
'''
table-flip any phrase you like!
If the expression contains spaces, please use quotes.
python flip_phrase.py fontlab
>>> (╯°□°)╯︵ qɐlʇuoɟ
'''
import sys
import unicodedata
unflipped = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 '
flipped = '∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz0ƖᄅƐㄣϛ9ㄥ86 '
flipping_guy = '(╯°□°)╯︵ '
input_text = sys.argv[-1]
input_text_ascii = unicodedata.normalize(
'NFD', input_text).encode('ascii', 'ignore')
output_flipped = ''
for ch_code in input_text_ascii:
ch = chr(ch_code)
try:
ch_index = unflipped.index(ch)
ch_flipped = flipped[ch_index]
except ValueError:
ch_flipped = ch
output_flipped += ch_flipped
print(flipping_guy + output_flipped[::-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment