Qwertypy

From Esolang
Jump to navigation Jump to search

Qwertypy is an esoteric Python clone created by User:Saka where every letter or number is turned into a number.

Since it's just a Python clone, it's probably not worth mentioning details.

How to Turn Python Code to Qwertypy Code

1. Make the code 1 line. For example (Truth Machine):

a=raw_input()\nif a=="0":\n\tprint("0")\nelif a=="1":\n\twhile True:\n\t\tprint("1")

2. Change every character to the index of said character in this string:

qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789~!@#$%^&*()_+-=[]{}\|;:,./<>? 

(Space at the end)
If the character is not in the "encoding string", leave it.
3. Separate each "encrypted" character with an underscore (_). The result for the Truth Machine example above would be

10_76_7_24_9_6_4_71_72_81_24_7_13_96_10_76_76_"_52_"_84_81_24_81_4_9_3_7_24_4_71_"_52_"_72_81_24_2_18_7_13_123_10_76_76_"_53_"_84_81_24_81_4_1_15_7_18_2_112_30_3_6_2_84_81_24_81_4_81_4_9_3_7_24_4_71_"_53_"_72

Or, you could use this script to encode

import random as r
char = ""
def encode(string):
    re = ""
    for i in range(0,len(string)):
        k = 0
        if string[i] == " ":
            k = r.randrange(92,150)
        elif string[i] not in char:
            re = re + string[i] + "_"
        else:
            while string[i] != char[k]:
                k += 1
        if k != 0:
            re = re + str(k) + "_"
    return re[:-1]

char = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789~!@#$%^&*()_+-=[]{}\|;:,./<>? "
s = input("String to encode? ")
print(encode(s))

Interpreters

Python:

def decode(string):
    re = ""
    slist = string.split("_")
    for i in range(0,len(slist)):
        if slist[i][0] in "0123456789":
            if int(slist[i]) > 92:
                re = re + " "
            else:
                re = re + char[int(slist[i])]
        elif slist[i] not in char:
            re = re + slist[i]
    return re
char = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789~!@#$%^&*()_+-=[]{}\|;:,./<>? "
code = input()
c = (decode(code))
c = c.encode('ascii').decode('unicode-escape')
exec(c)