Created
April 18, 2021 14:21
-
-
Save Ishtiaq11/935cd634788ba2700ca1756b1222828a to your computer and use it in GitHub Desktop.
Digital Stream by Ishtiaq Pias
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
import shutil,time,sys,random | |
MIN_STREAM_LENGTH = 5 | |
MAX_STREAM_LENGTH = 15 | |
DENSITY = 0.02 | |
WIDTH = shutil.get_terminal_size()[0] | |
COLUMN = [0] * WIDTH | |
STREAM_CHARS = ['0', '1', '2', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'] | |
PAUSE = 0.1 | |
print('Digital Streams by Ishtiaq Pias') | |
print('Press Ctrl-C to Stop') | |
time.sleep(1) | |
try: | |
while True: | |
for i, val in enumerate(COLUMN): | |
if val <= 0: | |
if random.random() <= DENSITY: | |
COLUMN[i] = random.randint(MIN_STREAM_LENGTH, MAX_STREAM_LENGTH) | |
print(' ', end='') | |
if val > 0: | |
print(random.choice(STREAM_CHARS), end='') | |
COLUMN[i] -= 1 | |
# print(val, end='') | |
print() | |
time.sleep(PAUSE) | |
# input('Press Enter to continue') | |
except KeyboardInterrupt: | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment