-3
\$\begingroup\$

This question already has an answer here:

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.
\$\endgroup\$

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

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
\$\endgroup\$
  • \$\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
-4
\$\begingroup\$

Python, 0 bytes

My program rotates the block of text by 720 degrees.

\$\endgroup\$
  • 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.