Taddeus Kroes 6 anni fa
parent
commit
00bb5f67af
2 ha cambiato i file con 21 aggiunte e 0 eliminazioni
  1. 21 0
      2019/08_image.py
  2. 0 0
      2019/input/8

+ 21 - 0
2019/08_image.py

@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+import sys
+from collections import Counter
+from operator import itemgetter
+
+# part 1
+w, h = 25, 6
+pix = [int(c) for c in sys.stdin.readline().rstrip()]
+counter = min((Counter(pix[i:i + w * h]) for i in range(0, len(pix), w * h)),
+              key=itemgetter(0))
+print(counter[1] * counter[2])
+
+# part 2
+img = [0] * (w * h)
+for start in reversed(range(0, len(pix), w * h)):
+    for i in range(w * h):
+        if pix[start + i] < 2:
+            img[i] = pix[start + i]
+
+for start in range(0, w * h, w):
+    print(''.join(' x'[img[start + i]] for i in range(w)))

File diff suppressed because it is too large
+ 0 - 0
2019/input/8


Some files were not shown because too many files changed in this diff