-4
\$\begingroup\$

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.
feersum
31.8k10 gold badges66 silver badges125 bronze badges
asked Sep 25, 2014 at 22:23
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Rotate in which direction? 90 degrees clockwise, or is that just an example? \$\endgroup\$ Commented Sep 25, 2014 at 22:43

2 Answers 2

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
answered Sep 25, 2014 at 22:42
\$\endgroup\$
2
  • \$\begingroup\$ Didn't he say that you cannot use an predefined method which rotates the text ? Seems like zip is doing that only \$\endgroup\$ Commented Sep 26, 2014 at 16:57
  • \$\begingroup\$ This can be improved by one char. See my answer to the question it duplicates \$\endgroup\$ Commented Sep 27, 2014 at 16:51
-4
\$\begingroup\$

Python, 0 bytes

My program rotates the block of text by 720 degrees.

answered Sep 25, 2014 at 22:38
\$\endgroup\$
1
  • 4
    \$\begingroup\$ Problem, it does not echo. \$\endgroup\$ Commented Sep 25, 2014 at 23:19

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.