Add main.py

This commit is contained in:
NJL
2026-06-26 17:42:45 +00:00
commit 426bd32214
+31
View File
@@ -0,0 +1,31 @@
import sys
try:
sys.stdout.reconfigure(encoding="utf-8")
sys.stdin.reconfigure(encoding="utf-8")
except (AttributeError, ValueError):
pass
RLE = ""
ALM = "؜"
PUNCTUATION = "!?.,;:…"
def transform(message):
trailing = ""
while message and message[-1] in PUNCTUATION:
trailing = message[-1] + trailing
message = message[:-1]
if "|" in message:
head, _, tail = message.partition("|")
body = head + RLE + trailing + RLE + RLE + tail.replace("|", RLE)
else:
body = message + RLE + trailing + RLE + RLE
return body + ALM + ALM + RLE
while True:
try:
print(transform(input("> ")))
except (KeyboardInterrupt, EOFError):
break