Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
dict(string.ascii_letters) + re.findall() solution in Clear category for Hacker Language by Olpag
import string
import re
class HackerLanguage:
def __init__(self):
self.text = ''
self.charbin = {c: f'{ord(c):b}' for c in string.ascii_letters}
self.charbin.update({' ': '1000000'})
self.binchar = {v:k for k,v in self.charbin.items()}
self.pattern = re.compile('[01]{7}|\d\d:\d\d|\d\d\.\d\d\.\d\d\d\d|.')
def write(self, text):
self.text += text
def delete(self, number):
self.text = self.text[:-number]
def send(self):
return ''.join(self.charbin.get(c, c) for c in self.text)
def read(self, cryptext):
return ''.join(self.binchar.get(c, c) for c in re.findall(self.pattern, cryptext))
March 11, 2020
Comments: