Skip to main content
6 of 8
added 11 characters in body
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL, 35 34 characters

Z"42Gi:qi!+lGqE!/tYo-KM!*|QYoZ}X]( 

Try it online!

###Explanation

This takes care of the reflections using the formulas

nx = 2*(Nx-1) px = abs(t/nx-round(t/nx))*nx 

where t is a time variable that increases in steps of 1, Nx is the maximum size along the x direction and px is the computed x position. Analogous formulas are used for the y coordinate.

A 2D char array of spaces is initially created, and then it is filled with character * at the computed x and y positions.

Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382