CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: Java

No Title

125 Views
Copy Code Show/Hide Line Numbers
import random
lifechance = .1 ## 10 % chance for life in square
board = []
for x in range (50):
    # '*' == life, '' == dead
    board.append(['*' if random.random()<lifechance else ''
                  for notcare in range(50)])
# make strings for lines replacing '' values (which are considered False) with ' '
print '\n'.join(''.join(life if life else ' '
                        for life in row)
                for row in board)
by tonyjv
  August 30, 2010 @ 11:27pm
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate