Files
python-aoc-2022/day18/part1.py
Sebastian Seedorf 2ed0ba2108 Day 18
2022-12-23 20:33:11 +01:00

17 lines
408 B
Python

#!/usr/bin/env python3
import numpy as np
lines = (x.strip() for x in open("input.txt"))
cnt = 0
matches = 0
cubes = set()
for line in lines:
x, y, z = map(int, line.split(","))
matches += sum((x+nx*s, y+ny*s, z+nz*s) in cubes for s in (1, -1) for nx, ny, nz in ((1, 0, 0), (0, 1, 0), (0, 0, 1)))
cnt += 1
cubes.add((x, y, z))
print(matches, cnt, len(cubes))
print(len(cubes)*6-matches*2)