Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
char2byte & byte2char solution in Clear category for Hacker Language by flpo
import re
def char2byte(c):
return '1000000' if c == ' ' else format(ord(c), 'b')
def byte2char(b):
return ' ' if b == '1000000' else chr(int(b, 2))
def resub(regex, f, s):
return regex.sub(lambda match: f(match.group()), s)
class HackerLanguage:
fixed = re.compile('[^\d{2}.\d{2}.\d{4}|\d{2}:\d{2}|\!|\?|\@|\$|\%|\.|\:]')
bytechar = re.compile('[0|1]{7}')
def __init__(self): self.s = ''
def write(self, s): self.s += s
def delete(self, i): self.s = self.s[:-i]
def send(self):
return resub(HackerLanguage.fixed, char2byte, self.s)
def read(self, message):
return resub(HackerLanguage.bytechar, byte2char, message)
June 16, 2018
Comments: