Last active
May 4, 2017 09:41
-
-
Save orsinium/eb2f601e11803333a036ff55e9904250 to your computer and use it in GitHub Desktop.
Field generator for Conway's Game of Life
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#author: Gram ([email protected]) | |
#description: Field generation for Conway's Game of Life | |
from random import choice | |
n = int(input('Введите размер поля:\n> ')) | |
r = input('Заполнить его случайно "живыми"?:\n> ').lower() | |
if 'д' in r or 'y' in r: | |
r = True | |
else: | |
r = False | |
f = [] | |
for i in range(n): | |
for j in range(n): | |
if not r: | |
f.append('.') | |
else: | |
f.append(choice(('.', '.', '.', '.', '#'))) | |
f.append('\n') | |
open('in', 'w').write(''.join(f)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment