fork download
  1. g=lambda s:'\n'.join("".join(s)for s in zip(*[k[-i%len(k):]+k[:-i%len(k)]for i,k in enumerate(zip(*s.split('\n')))]))
  2.  
  3. testCases = [r"""Hello, world!
  4. I am another
  5. string to be
  6. twisted! """,
  7. r"""\\\\\\\\\\\\
  8. ............
  9. ............
  10. ............""",
  11. r"""abcdefg
  12. .......""",
  13. r"""abcdefghij
  14. ..........
  15. ..........""",
  16. r"""\\\\.....././
  17. ...../.......
  18. ........././.
  19. ..../.^\\....""",
  20. r"""cdeab
  21. deabc
  22. eabcd
  23. abcde""",
  24. r"""aeimquy37
  25. bfjnrvz48
  26. cgkosw159
  27. dhlptx260""",
  28. r"""abcdefghi
  29. jklmnopqr
  30. stuvwxyz1
  31. 234567890"""]
  32.  
  33. for case in testCases:
  34. print "Input: "
  35. print case
  36. print ""
  37. print "Output: "
  38. print g(case)
  39. print "--------------------------------"# your code goes here
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
Input: 
Hello, world!
I am another 
string to be 
twisted!     

Output: 
Hwrmoe oo br!
Ieii ,dttr e 
s lsna !ohl  
ttaltgnw  ed 
--------------------------------
Input: 
\\\\\\\\\\\\
............
............
............

Output: 
\...\...\...
.\...\...\..
..\...\...\.
...\...\...\
--------------------------------
Input: 
abcdefg
.......

Output: 
a.c.e.g
.b.d.f.
--------------------------------
Input: 
abcdefghij
..........
..........

Output: 
a..d..g..j
.b..e..h..
..c..f..i.
--------------------------------
Input: 
\\\\.....././
...../.......
........././.
..../.^\\....

Output: 
\.........../
.\....^..../.
..\../.\../..
...\/...\/...
--------------------------------
Input: 
cdeab
deabc
eabcd
abcde

Output: 
cbbbb
ddccc
eeedd
aaaae
--------------------------------
Input: 
aeimquy37
bfjnrvz48
cgkosw159
dhlptx260

Output: 
ahknqx147
beloru258
cfipsvy69
dgjmtwz30
--------------------------------
Input: 
abcdefghi
jklmnopqr
stuvwxyz1
234567890

Output: 
a3ume7yqi
jb4vnf8zr
skc5wog91
2tld6xph0
--------------------------------