Skip to content

Instantly share code, notes, and snippets.

@hanss314
Created December 11, 2020 06:27
Show Gist options
  • Save hanss314/fbed58499374d3eeb438449579f46a49 to your computer and use it in GitHub Desktop.
Save hanss314/fbed58499374d3eeb438449579f46a49 to your computer and use it in GitHub Desktop.
Advent of Code Day 11 Part 1 Solution
@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
# 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)
# 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