Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Hacker Language by pokosasa
class HackerLanguage:
def __init__(self):
self.text=""
def write(self,text):
self.text+=text
def delete(self,n):
self.text=self.text[:-n]
def send(self):
message=""
for c in self.text:
if c.isalpha():
message+=format(ord(c),"b")
elif c==" ":
message+="1000000"
else:
message+=c
return message
def read(self,text):
message=""
while text:
if set(text[:7])<={"0","1"}:
message+=chr(int(text[:7],2)).replace("@"," ")
text=text[7:]
else:
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!")
Nov. 26, 2019
Comments: