Advertisement
ad2bg

Pyramidic

Aug 3rd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. n = int(input())
  2. d = {}
  3. best_c = ''
  4. best_x = 0
  5.  
  6.  
  7. def track_best(c):
  8.     global best_c, best_x
  9.     x = d[c]
  10.     if x > best_x:
  11.         best_c = c
  12.         best_x = x
  13.  
  14.  
  15. def verify(line):
  16.     keys = list(d.keys())[:]
  17.     for c in keys:
  18.         x = d[c] + 2
  19.         while x > 0:
  20.             if line.find(c * x) < 0:
  21.                 x -= 2
  22.                 if x < 0:
  23.                     del d[c]
  24.             else:
  25.                 d[c] = x
  26.                 track_best(c)
  27.                 break
  28.  
  29.     for c in line:
  30.         if c not in d:
  31.             d[c] = 1
  32.             track_best(c)
  33.  
  34.  
  35. for i in range(n):
  36.     line = input()
  37.  
  38.     if i == 0:
  39.         for c in line:
  40.             if c not in d:
  41.                 d[c] = 1
  42.                 track_best(c)
  43.     else:
  44.         verify(line)
  45.  
  46. [print(best_c * i) for i in range(1, best_x + 1, 2)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement