Skip to content

Instantly share code, notes, and snippets.

@wasi0013
Created January 10, 2024 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wasi0013/7a19a8dec1b45e63039c0fbe920b7e69 to your computer and use it in GitHub Desktop.
Save wasi0013/7a19a8dec1b45e63039c0fbe920b7e69 to your computer and use it in GitHub Desktop.
Convert ASCII texts to upside down text.
def flip(string):
"""Flips text upside down.
>>> flip("Hello World.")
'˙pןɹoM oןןǝH'
"""
d = {'a': 'ɐ', 'b': 'q', 'c': 'ɔ', 'd': 'p', 'e': 'ǝ', 'f': 'ɟ', 'g': 'ƃ', 'h': 'ɥ', 'i': 'ı', 'j': 'ɾ', 'k': 'ʞ', 'l': 'ן', 'm': 'ɯ', 'n': 'u', 'o': 'o', 'p': 'd', 'q': 'b', 'r': 'ɹ', 's': 's', 't': 'ʇ', 'u': 'n', 'v': 'ʌ', 'w': 'ʍ', 'x': 'x', 'y': 'ʎ', 'z': 'z', 'A': '∀', 'B': '𐐒', 'C': 'Ɔ', 'D': '◖', 'E': 'Ǝ', 'F': 'Ⅎ', 'G': '⅁', 'H': 'H', 'I': 'I', 'J': 'ſ', 'K': '⋊', 'L': '˥', 'M': 'W', 'N': 'N', 'O': 'O', 'P': 'Ԁ', 'Q': 'Ό', 'R': 'ᴚ', 'S': 'S', 'T': '⊥', 'U': '∩', 'V': 'Λ', 'W': 'M', 'X': 'X', 'Y': '⅄', 'Z': 'Z', '0': '0', '1': 'Ɩ', '2': 'ᄅ', '3': 'Ɛ', '4': 'ㄣ', '5': 'ϛ', '6': '9', '7': 'ㄥ', '8': '8', '9': '6', '.': '˙', ' ': ' ', '\n': '\n', '\t': '\t'}
return "".join(map(d.__getitem__, string))[::-1]
def unflip(string):
"""Converts upside down text to normal.
>>> unflip("˙pןɹoʍ oןןǝH")
'Hello world.'
"""
d = {'ɐ': 'a', 'q': 'b', 'ɔ': 'c', 'p': 'd', 'ǝ': 'e', 'ɟ': 'f', 'ƃ': 'g', 'ɥ': 'h', 'ı': 'i', 'ɾ': 'j', 'ʞ': 'k', 'ן': 'l', 'ɯ': 'm', 'u': 'n', 'o': 'o', 'd': 'p', 'b': 'q', 'ɹ': 'r', 's': 's', 'ʇ': 't', 'n': 'u', 'ʌ': 'v', 'ʍ': 'w', 'x': 'x', 'ʎ': 'y', 'z': 'z', '∀': 'A', '𐐒': 'B', 'Ɔ': 'C', '◖': 'D', 'Ǝ': 'E', 'Ⅎ': 'F', '⅁': 'G', 'H': 'H', 'I': 'I', 'ſ': 'J', '⋊': 'K', '˥': 'L', 'W': 'M', 'N': 'N', 'O': 'O', 'Ԁ': 'P', 'Ό': 'Q', 'ᴚ': 'R', 'S': 'S', '⊥': 'T', '∩': 'U', 'Λ': 'V', 'M': 'W', 'X': 'X', '⅄': 'Y', 'Z': 'Z', '0': '0', 'Ɩ': '1', 'ᄅ': '2', 'Ɛ': '3', 'ㄣ': '4', 'ϛ': '5', '9': '6', 'ㄥ': '7', '8': '8', '6': '9', '˙': '.', ' ': ' ', '\n': '\n', '\t': '\t'}
return "".join(map(d.__getitem__, string))[::-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment