Skip to content

Instantly share code, notes, and snippets.

@feulf
Created May 15, 2022 13:45
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 feulf/f8804c4b6841bf3dbfd06cf72ada4541 to your computer and use it in GitHub Desktop.
Save feulf/f8804c4b6841bf3dbfd06cf72ada4541 to your computer and use it in GitHub Desktop.
This code generates random patterns with ' ', +, and -
import random
symbols = ['-', '+', ' ', ' ', ' ', ' ']
def get_symbol(seed: int = 1):
# random.seed(seed)
r = int(random.random() * 1000)
return symbols[r % len(symbols)]
matrix = [[get_symbol(i + j) for i in range(40)] for j in range(20)]
def print_matrix():
output = ""
for i in range(0, len(matrix)):
output += "\n"
for j in range(0, len(matrix[i])):
output += matrix[i][j]
print(output)
def mirror_matrix():
for i in range(20):
matrix[i] += reversed(matrix[i])
for i in range(19, 0, -1):
matrix.append(matrix[i])
mirror_matrix()
print_matrix()
@feulf
Copy link
Author

feulf commented May 15, 2022

example output
Screen Shot 2022-05-15 at 9 47 03 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment