Taddeus Kroes il y a 6 ans
Parent
commit
00bb5f67af
2 fichiers modifiés avec 21 ajouts et 0 suppressions
  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)))

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
2019/input/8


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff