Advertisement
Guest User

Reibello AoC 6

a guest
Dec 6th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. #aoc2016_6.py
  2. input_file_object = open("aoc16_input_6a.txt")
  3. input_as_string = input_file_object.read()
  4. input_file_object.close()
  5.  
  6. input_separated = input_as_string.split('\n')
  7.  
  8. cols = ['','','','','','','','']
  9. msg = ''
  10.  
  11. def infrequent_char(text):
  12.     charset = ''.join(sorted(text))
  13.     mincount = len(text)
  14.     minchar = None
  15.     for item in charset.lower():
  16.         charcount = text.count(item)
  17.         if charcount < mincount :
  18.             mincount = charcount
  19.             minchar = item
  20.     return minchar
  21.  
  22. for i in range(len(input_separated)):
  23.     for j in range(len(cols)):
  24.         cols[j] += cols[j].join(input_separated[i][j])
  25.  
  26. for x in range(len(cols)):
  27.     res = infrequent_char(cols[x])
  28.     msg += msg.join(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement