Advertisement
Guest User

Day 8 Part 1 AOC 2019

a guest
Dec 12th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. numbers = []
  2.  
  3. def layer(l, n):
  4.     for i in range(0, len(l), n):
  5.         yield l[i:i + n]
  6.  
  7. def main():
  8.     global numbers
  9.  
  10.     f = open("Day8Numbers.txt", "r")
  11.     cond = f.readline()
  12.     nums = []
  13.  
  14.     for x in str(cond):
  15.         if x == "\n":
  16.             break
  17.         else:
  18.             nums.append(int(x))
  19.  
  20.     halfLayered = list(layer(nums, 25))
  21.     numbers = list(layer(halfLayered, 6))
  22.  
  23.     print(numbers)
  24.  
  25. def part1():
  26.     global numbers
  27.     total = []
  28.  
  29.     cond = 0
  30.     for x in numbers:
  31.         if cond == 0:
  32.             print("initiated")
  33.         else:
  34.             total.append(count)
  35.  
  36.         cond = 1
  37.         count = 0
  38.         for y in x:
  39.             for z in y:
  40.                 if z == 0:
  41.                     count += 1
  42.     num1 = 0
  43.     num2 = 0
  44.  
  45.     for x in range(len(total)):
  46.         if total[x] == max(total):
  47.             maxNum = x
  48.  
  49.     for x in numbers:
  50.         if x == numbers[maxNum]:
  51.             for y in x:
  52.                 for z in y:
  53.                     if z == 1:
  54.                         num1 += 1
  55.                     elif z == 2:
  56.                         num2 += 1
  57.  
  58.     print(num1 * num2)
  59.  
  60. main()
  61. part1()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement