Advertisement
Guest User

py

a guest
May 22nd, 2016
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. from copy import copy
  2. from math import ceil
  3. a = input()
  4. while a != "0":
  5.     p = list(map(int, a.split()))
  6.     n = p[0]
  7.     p = p[1:]
  8.     s = input()
  9.     s += " "*max(0, len(p)-len(s))
  10.  
  11.     l = list(s)
  12.     spl = [l[i*len(p):i*len(p)+len(p)] for i in range(ceil(len(l)/len(p)))]
  13.     if len(spl[-1]) < len(spl[0]):
  14.         spl[len(spl)-1] += " "*(len(spl[0])-len(spl[-1]))
  15.     nspl = [[" " for j in range(len(p))] for i in range(ceil(len(l)/len(p)))]
  16.  
  17.     for i in range(len(spl)):
  18.         for j in range(len(p)):
  19.             nspl[i][j] = copy(spl[i][p[j]-1])
  20.  
  21.     ans = "'"
  22.     for i in nspl:
  23.         ans += "".join(i)
  24.     ans += "'"
  25.     print(ans)
  26.     a = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement