# Rotate a Block of Text [duplicate]

## Rules

• Write a program in a language of your choice.
• That program is designed to rotate a block of text. Example:

BOB   90 deg  DCB
CAT    -->    OAO
DOG    CW     GTB

• You may assume the blocks of text are loaded into a variable block.
• You may assume a square block, but of any size.
• You may assume the line-endings are \n.
• You're not allowed to use a library that already rotates blocks of text.
• Code Golf rules, shortest program wins.

## marked as duplicate by xnor, Martin Ender, algorithmshark, ace, proud haskellerSep 25 '14 at 23:34

• Rotate in which direction? 90 degrees clockwise, or is that just an example? – algorithmshark Sep 25 '14 at 22:43

# GolfScript, 11 characters

n/-1%zip n*


Explanation:

n/  # split on newline
-1% # reverse array
zip # "rotate" (will turn ['abc' 'def' 'ghi'] into ['adg' 'beh' 'cfi'])
n*  # join with newline again

• Didn't he say that you cannot use an predefined method which rotates the text ? Seems like zip is doing that only – Optimizer Sep 26 '14 at 16:57
• This can be improved by one char. See my answer to the question it duplicates – Peter Taylor Sep 27 '14 at 16:51

# Python, 0 bytes



My program rotates the block of text by 720 degrees.

• Problem, it does not echo. – PyRulez Sep 25 '14 at 23:19