Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
17-liner: The Language was Hacked Successfully! solution in Clear category for Hacker Language by Stensen
from re import compile, split, findall
from itertools import zip_longest
pattern = compile(r'[.:!?@$%]|\d{2}\.\d{2}\.\d{4}|\d{2}\:\d{2}')
class HackerLanguage:
def __init__(self): self.text: str = ''
def write(self, text: str):
self.text += text
def delete(self, N: int):
self.text = self.text[:len(self.text)-N] if N < len(self.text) else ''
def send(self):
conv = split(pattern, self.text)
non_conv = findall(pattern, self.text)
return ''.join([''.join(map(lambda c:'1000000' if c.isspace() else bin(ord(c))[2:],list(i)))+j for i,j in zip_longest(conv, non_conv, fillvalue='')])
def read(self, text: str):
conv = [findall(r'\d{7}', t) for t in split(pattern, text)]
non_conv = findall(pattern, text)
return ''.join([''.join(map(lambda k:' ' if k=='1000000' else chr(int(k,2)),i))+j for i,j in zip_longest(conv, non_conv, fillvalue='')])
Oct. 13, 2020