Created
March 31, 2023 14:08
-
-
Save mirwox/a238fc8d6d2a1ff0d50fe6706759a632 to your computer and use it in GitHub Desktop.
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
matrix = [[' ' for j in range(50)] for i in range(15)] | |
xa = 5 | |
ya = 5 | |
xb = 45 | |
yb = 15 | |
# Calculate the parameters of the curve y = ax + b | |
a = (yb - ya) / (xb - xa) | |
b = ya - a * xa | |
# Draw the curve on the matrix | |
for x in range(xa, xb): | |
y = round(a * x + b)%15 | |
matrix[y][x] = '*' | |
# Print the matrix | |
for row in matrix: | |
print(''.join(row)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment