Advertisement
Korotkodul

1915D - Нестандартная обработка языка

Jul 17th, 2024
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1.  
  2. t = int(input())
  3. for k in range(t):
  4.     n = int(input())
  5.     s = input()
  6.     if n == 2:
  7.         ptint(s)
  8.         continue
  9.     if n == 3:
  10.         print(s)
  11.         continue
  12.     hlp = s.replace('a', 'V').replace('e', 'V').replace('b', 'C').replace('c', 'C').replace('d', 'C')
  13.     i = 0
  14.     #print("hlp", hlp)
  15.     ans = ''
  16.     while True:
  17.         #print("i ", i)
  18.         if i == n - 3:
  19.             #print("A")
  20.             ans += s[n - 3: n]
  21.             break
  22.         elif i == n - 2:
  23.             #print("B")
  24.             ans += s[n - 2: n]
  25.             break
  26.         elif hlp[i + 3] == 'C':
  27.             #print("i ", i)
  28.             ans += s[i] + s[i + 1] + s[i + 2] + '.'
  29.             i += 3
  30.         elif hlp[i + 3] == 'V':
  31.             ans += s[i] + s[i + 1] + '.'
  32.             i += 2
  33.     print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement