Created
March 2, 2020 13:52
-
-
Save notexactlyawe/5a9e32015a13d71f78247c31b718c570 to your computer and use it in GitHub Desktop.
Prints a grid of '1's to your terminal and then slowly changes them to '0's
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 random | |
import time | |
import shutil | |
width, height = shutil.get_terminal_size() | |
width = width // 2 | |
grid = [] | |
for row in range(height): | |
grid.append([1 for _ in range(width)]) | |
co_ords = [(x, y) for x in range(height) for y in range(width)] | |
def print_grid(): | |
for row in grid: | |
print(' '.join([str(i) for i in row])) | |
for num in range(width*height): | |
print_grid() | |
to_flip = random.choice(co_ords) | |
co_ords.remove(to_flip) | |
grid[to_flip[0]][to_flip[1]] = 0 | |
time.sleep(0.1) | |
print_grid() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment