Created
May 15, 2022 13:45
-
-
Save feulf/f8804c4b6841bf3dbfd06cf72ada4541 to your computer and use it in GitHub Desktop.
This code generates random patterns with ' ', +, and -
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 | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example output
