Last active
December 8, 2019 10:29
-
-
Save erikaderstedt/bc0bebf60b528e97f38a8b5932ab4efe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python3 | |
# -*- coding: utf8 -*- | |
import numpy as np | |
m = np.fromfile('8.in', dtype=np.uint8, count=25*6*100).reshape((100,6,25)) - 48 | |
f = m.reshape((m.shape[0], m.shape[1]*m.shape[2])) | |
best_layer = np.argmin(f.shape[1] - np.count_nonzero(f, axis=1)) | |
print("Pt 1:", (f.shape[1] - np.count_nonzero(f[best_layer,:]-1)) * (f.shape[1] - np.count_nonzero(f[best_layer,:]-2))) | |
print("Pt 2:") | |
for r in range(m.shape[1]): | |
for c in range(m.shape[2]): | |
color = m[np.argwhere(m[:,r,c] != 2)[0],r,c] | |
print('*' if color == 1 else ' ', end='') | |
print(' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment