Skip to main content
1 of 6
Karl Napf
  • 4.5k
  • 14
  • 31

Python 180 172 Bytes

def r(m,n,x,y,t): s=([' ']*m+['\n'])*n a=b=1 for _ in range(t): s[x+y*m+y],x,y='xo'[i<t-1],x+a,y+b if x==0 or x==m-1:a=-a if y==0 or y==n-1:b=-b print ''.join(s) 

Had to use a list of characters because python does not support string item assignement. The x+y*m+y part is from x+y*(m+1) because of the '\n' add each line end

Edit1: right after posting, saw how to get rid of the overwriting 'x'

Karl Napf
  • 4.5k
  • 14
  • 31