Skip to main content
4 of 5
added 28 characters in body
mbomb007
  • 23.6k
  • 7
  • 66
  • 143

##Python 2.7: 126 109 -10-50 = 49

Got rid of the hard-coded starting point - now starts at random point. Because of this, I needed randint, so I decided to use that instead of choice for the offset. Used the (-1)**bool trick for that.

from random import randint as r;p=r(0,29) for i in range(30): print' '*p+'.'+' '*(29-p);p+=(-1)**(r(0,29)<p) 

Some great answers here. First attempt in Python, thinking about improvements. Not helped by the need for an import.

-10 - yes 30 chars + \n on each line

-50 - the further away from the centre, the more likely a move the other way (accomplished by building a list with a different number of +/i offsets)

Previous attempt:

from random import choice;p,l=15,[] for i in range(30): q=29-p;l+=[' '*p+'.'+' '*q];p+=choice([1]*q+[-1]*p) print'\n'.join(l)