Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Hacker Language by Sim0000
class HackerLanguage(object):
def __init__(self):
self.text = ''
def write(self, text):
self.text += text
def delete(self, n):
self.text = self.text[:-n]
def send(self):
ciphertext = ''
for c in self.text:
if c == ' ':
ciphertext += '1000000'
elif c.isdigit() or c in '!?@$%.:':
ciphertext += c
else:
ciphertext += f'{ord(c):07b}'
return ciphertext
def read(self, text):
message = ''
while text:
if len(text) < 7:
message += text
text = ''
else:
try:
n = int(text[:7], 2)
if n == 0x40: n = 0x20
message += chr(n)
text = text[7:]
except:
message += text[0]
text = text[1:]
return message
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
message_1 = HackerLanguage()
message_1.write("secrit")
message_1.delete(2)
message_1.write("et")
message_2 = HackerLanguage()
assert message_1.send() == "111001111001011100011111001011001011110100"
assert message_2.read("11001011101101110000111010011101100") == "email"
print("Coding complete? Let's try tests!")
June 18, 2018
Comments: