Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import collections, string
  3. x = 0
  4. f = open('input.txt')
  5. key = string.ascii_lowercase
  6.  
  7. def decrypt(n, ciphertext):
  8.     result = ''
  9.     for l in ciphertext:
  10.         try:
  11.             i = (key.index(l) + int(n)) % 26
  12.             result += key[i]
  13.         except ValueError:
  14.             result += l
  15.     return result
  16.  
  17.  
  18. for line in f.readlines():
  19.     line = line.strip()
  20.     l_array = line.replace('[','-').replace(']','').split('-')
  21.     encroom = l_array[len(l_array)-1]
  22.     sid = l_array[len(l_array)-2]
  23.     room_name = ''.join(l_array[:len(l_array)-2])
  24.     countz = collections.Counter(room_name)
  25.     countz2 =  list(sorted(countz.iteritems(),key=lambda(k,v):(-v,k)))
  26.     if 'north' in decrypt(sid,room_name):
  27.    
  28.         print decrypt(sid,room_name),sid
  29. print x
  30.  
  31.     #print sorted(countz.iteritems(),key=lambda(k,v):(-v,k))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement