Last active
March 13, 2021 07:14
-
-
Save sXakil/a7377acba95f8ba2b7dddfaf24339c27 to your computer and use it in GitHub Desktop.
Python code for the string generator used in this ASCII art code: https://gist.github.com/sXakil/d7e88da11830dc1370cb7f89b5ebaae1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Copy and paste any shape using space and '|', add an '*' to indicate the end of your stream | |
example input: | |
|| || | |
|| || || | |
|| || || | |
||| |||* | |
STart each line with at least one space and make sure your shape is no more than 60 characters in width to maintain general ASCII range | |
""" | |
import re | |
generator = '' | |
while True: | |
line = input() | |
chunks = [c.group(0) for c in re.finditer(r"(\|| )\1*", line)] | |
for chunk in chunks: | |
generator += chr(64 + len(chunk)) | |
if line[len(line) - 1] == '*': | |
break | |
generator += '..' # use one '.' if using Github Gist version | |
print(generator) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment