Created
December 11, 2020 06:27
-
-
Save hanss314/fbed58499374d3eeb438449579f46a49 to your computer and use it in GitHub Desktop.
Advent of Code Day 11 Part 1 Solution
This file contains 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
@RULE AoC | |
@TABLE | |
n_states:3 | |
neighborhood:Moore | |
symmetries:permute | |
var i={0,1} | |
var j={0,1} | |
var k={0,1} | |
var l={0,1} | |
var m={0,1} | |
var n={0,1} | |
var o={0,1} | |
var p={0,1} | |
var q={0,1,2} | |
var r={0,1,2} | |
var s={0,1,2} | |
var t={0,1,2} | |
1,i,j,k,l,m,n,o,p,2 | |
2,2,2,2,2,q,r,s,t,1 | |
@COLORS | |
1 255 0 0 | |
2 0 0 255 |
This file contains 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
# save the final state of the golly simulation, remove the header with a text editor, and run this python script on the file | |
from sys import argv | |
inp = open(argv[1], 'r').read().strip().replace('\n', '').replace('$', '') | |
num = '' | |
count = 0 | |
for c in inp: | |
if c in '0123456789': | |
num += c | |
continue | |
if c == 'B': | |
if num: count += int(num) | |
else: count += 1 | |
num = '' | |
print(count) |
This file contains 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
# header for input. x and y don't really matter | |
# input was processed with %s/L/A/g and %s/\n/$\n/g | |
x = 10, y = 10, rule = AoC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment