mid-kid
4 years ago
3 changed files with 35 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||||
|
#!/usr/bin/env python3 |
||||
|
|
||||
|
from sys import argv |
||||
|
from itertools import product |
||||
|
|
||||
|
i = {(x,y,0) for y,iy in enumerate(open(argv[1]).read().splitlines()) for x,ix in enumerate(iy) if ix == "#"} |
||||
|
i4 = {(x,y,z,0) for x,y,z in i} |
||||
|
|
||||
|
def f(i,m): |
||||
|
ni = set() |
||||
|
da = [x for x in product(*([(-1,0,1)]*m)) if x != (0,)*m] |
||||
|
for p in product(*map(lambda x: range(min(x)-1,max(x)+2), zip(*i))): |
||||
|
n = [tuple(sum(x) for x in zip(p,d)) for d in da] |
||||
|
c = sum(1 for p in n if p in i) |
||||
|
if p in i and 2 <= c <= 3: |
||||
|
ni.add(p) |
||||
|
elif c == 3: |
||||
|
ni.add(p) |
||||
|
return ni |
||||
|
|
||||
|
for c in range(6): |
||||
|
i = f(i,3) |
||||
|
i4 = f(i4,4) |
||||
|
print(len(i)) |
||||
|
print(len(i4)) |
@ -0,0 +1,8 @@ |
|||||
|
##..#### |
||||
|
.###.... |
||||
|
#.###.## |
||||
|
#....#.. |
||||
|
...#..#. |
||||
|
#.#...## |
||||
|
..#.#.#. |
||||
|
.##...#. |
@ -0,0 +1,2 @@ |
|||||
|
209 |
||||
|
1492 |
Loading…
Reference in new issue