• 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.
  • 1
    \$\begingroup\$ Rotate in which direction? 90 degrees clockwise, or is that just an example? \$\endgroup\$ – algorithmshark Sep 25 '14 at 22:43

GolfScript, 11 characters

n/-1%zip n*


n/  # split on newline
-1% # reverse array
zip # "rotate" (will turn ['abc' 'def' 'ghi'] into ['adg' 'beh' 'cfi'])
n*  # join with newline again
  • \$\begingroup\$ Didn't he say that you cannot use an predefined method which rotates the text ? Seems like zip is doing that only \$\endgroup\$ – Optimizer Sep 26 '14 at 16:57
  • \$\begingroup\$ This can be improved by one char. See my answer to the question it duplicates \$\endgroup\$ – Peter Taylor Sep 27 '14 at 16:51

Python, 0 bytes

My program rotates the block of text by 720 degrees.

  • 4
    \$\begingroup\$ Problem, it does not echo. \$\endgroup\$ – PyRulez Sep 25 '14 at 23:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.