Skip to content

Instantly share code, notes, and snippets.

@notexactlyawe
Created March 2, 2020 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notexactlyawe/5a9e32015a13d71f78247c31b718c570 to your computer and use it in GitHub Desktop.
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
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