Skip to content

Instantly share code, notes, and snippets.

@orsinium
Last active May 4, 2017 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orsinium/eb2f601e11803333a036ff55e9904250 to your computer and use it in GitHub Desktop.
Save orsinium/eb2f601e11803333a036ff55e9904250 to your computer and use it in GitHub Desktop.
Field generator for Conway's Game of Life
#author: Gram (master_fess@mail.ru)
#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