SHARE
TWEET

Untitled

a guest Dec 8th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with open('input') as f:
  2.     img = f.read().strip('\n')
  3.  
  4. w = 25
  5. h = 6
  6. s = len(img)
  7. layers = [img[i:i+w*h] for i in range(0, s, w*h)]
  8.  
  9. # Part 1
  10. zeros = [x.count('0') for x in layers]
  11. index = zeros.index(min(zeros))
  12. print(layers[index].count('1')*layers[index].count('2'))
  13.  
  14. # Part 2
  15. result = ''
  16. for i in range(w*h):
  17.     j = 0
  18.     while True:
  19.         if int(layers[j][i]) == 1:
  20.             result += 'x'
  21.             break
  22.         elif int(layers[j][i]) == 0:
  23.             result += ' '
  24.             break
  25.         else:
  26.             j += 1
  27.  
  28. for i in range(0, w*h, w):
  29.     print(result[i:i+w])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top