Skip to content

Instantly share code, notes, and snippets.

@shawntan
Created May 3, 2020 01:37
Show Gist options
  • Save shawntan/68aacf4faf732fa9bc1f39bf6fd9ce4b to your computer and use it in GitHub Desktop.
Save shawntan/68aacf4faf732fa9bc1f39bf6fd9ce4b to your computer and use it in GitHub Desktop.
rules = {'xxx': ' ','xx ': ' ', 'x ': 'x','x x':' ',' xx':'x',' x ':'x', ' x': 'x', ' ':' '}
initial_string = " " * 100 + "x" + " " * 100
prev_string = initial_string
for i in range(90):
print(prev_string)
prev_string = ''.join(rules.get(prev_string[i - 1:i + 2], ' ') for i in range(len(initial_string)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment