Skip to content

Instantly share code, notes, and snippets.

@mirwox
Created March 31, 2023 14:08
Show Gist options
  • Save mirwox/a238fc8d6d2a1ff0d50fe6706759a632 to your computer and use it in GitHub Desktop.
Save mirwox/a238fc8d6d2a1ff0d50fe6706759a632 to your computer and use it in GitHub Desktop.
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