Skip to main content
4 of 6
added 75 characters in body
Karl Napf
  • 4.5k
  • 14
  • 31

Python 180 172 171 163 Bytes

(-2 Bytes with Python3)

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

To save 2 more bytes with Python3 (thanks to shooqie) replace second line with

 s=[*' '*m,'\n']*n 

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'

Edit2: space after print

Edit3: using < and > instead ==, also tabs for 2nd indentation

Karl Napf
  • 4.5k
  • 14
  • 31