Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
scanner with code dictionary solution in Creative category for Hacker Language by ogoro
import re
TRANSPARENT = lambda _, token: token
CHAR_TO_BITS = lambda _, token: f'{ord(token):<07b}'
BITS_TO_CHAR = lambda _, token: chr(int(token.replace('1000000', '100000'), 2))
ENCODE = {r'\d|[^\w\s]': TRANSPARENT, r'.': CHAR_TO_BITS}
DECODE = {r'[0|1]{7}': BITS_TO_CHAR, r'.': TRANSPARENT}
class HackerLanguage:
_message = ''
@staticmethod
def transcode(message, code_dictionary):
scanner = re.Scanner(list(code_dictionary.items()))
tokens, unrecognised = scanner.scan(message)
return ''.join(tokens)
def write(self, text):
self._message += text
def delete(self, symbol_count):
self._message = self._message[:-symbol_count]
def send(self):
return self.transcode(self._message, ENCODE)
def read(self, text):
return self.transcode(text, DECODE)
March 9, 2021
Comments: