# Rotate simple ASCII art [closed]

This is similar to a previous question on this site, but with much simpler rules, so we should get much shorter results (in bytes):

• Input: ASCII art with only two possible characters: space and '#'.
• Output: Input sequence rotated 90 degrees counter-clockwise.

Winner is answer with least number of bytes including length of language name.

• Any special reason for the "including length of language name"? Feb 5 '14 at 21:56
• Are input lines equal length (padded with spaces if necessary)? Feb 5 '14 at 22:04
• @nbubis Don't think that this is really such a incentive. Feb 5 '14 at 22:10
• Why try to penalise esoteric languages in the first place? If your goal is to encourage other languages, focus on encouraging other languages effectively rather than penalising esoterics ineffectively. StackExchange even has a built-in method to encourage a particular type of answer: the bounty. Feb 5 '14 at 23:39
• So, say, JavaScript (a normal, non-esoteric language) has a higher penalty than APL or J or K, and the same penalty as GolfScript? Not sure how that "encourages non esoteric languages" at all...
– Doorknob
Feb 6 '14 at 1:36

# K, 1+1

+


.

k)+("# # #";" # # ";"#####")
"# #"
" ##"
"# #"
" ##"
"# #"

• I don't know k, but I count k ) + and than the matrix, thats 3 characters right? And than you need to add the K as one character. So the total is 4, not 1 Jul 4 '14 at 10:54
• The k) is just a prompt, like >>> in a python interpreter. It doesn't need to be there at all Jul 4 '14 at 15:34

## GolfScript (10 chars + 10)

n/zip-1%n*


Online demo

Note: as Tomas correctly observed in the comments, I'm assuming that the input is rectangular. This seems reasonable, because it is explicitly stated in the specification of the question which this one aims to simplify.

• You are assuming that all the lines are of the same length, which was not specified in the rules. I think you can still post your solution but the limitation should be stated in the asnwer. Feb 6 '14 at 11:55

# MATLAB - 14

rot90(a)


Where 'a' is the input art, in matrix form. 8 characters in the code, 6 in the name. 8 + 6 = 14.

## J, 16+1 characters

|.|:[;._2[1!:1[3


Usage (first 3 lines of # is the input, the rest is the output):

   |.|:[;._2[1!:1[3
# # #
# #
#####
# #
##
# #
##
# #


Explanation:

1!:1[3 take multi-line input from the keyboard
[ used as a separator
[;._2 chop the string into lines
|: transpose
|. reverse

12 characters to take an process the input, and 4 characters to complete the task.

Python 3.X 56-Chars

print('\n'.join(map(''.join,zip(*input().split('\n')))))


Demo

>>> print '\n'.join(map(''.join,zip(*raw_input().split('\n'))))
# # #
# #
#####
# #
##
# #
##
# #
# ## # #
## # #
# ######
##
# #

• A bit late, but aren't you supposed to add 6 chars because "Python" has six letters? Nov 1 '16 at 17:18

# R, 4+1

t(a)


Where 'a' is the input art, in matrix form. Language is Cran R, function to transform/rotate a martix is t.

• The score is 5: 4 + 1 (the length of R) Sep 13 '16 at 21:12

s=[*$<];s[0].size.downto(1){|i|puts s.map{|l|l[i-1]}*''}  • I think there's a syntax error somewhere. Feb 5 '14 at 23:58 • @nbubis All lines must be of the same length (padded with spaces). Also an updated version of Ruby is probably required. Feb 6 '14 at 0:03 # Perl, 44 chars $/=$i--;$_=<>;say/(.).{$i}$/gmwhile!++$i||$1


Assuming all rows have equal length.

# J (4+1)

|:|.


Expected input as a string matrix. Usage:

   a=: >'# # #';' # #';'#####'
a
# # #
# #
#####
|:|.a
# #
##
# #
##
# #


## Bash (144 + 4) (131 + 4)

Assumes input is in a file with newlines to delimit end of row.
Assumes each row has the same number of characters.
Assumes first argument is path to file.

t=sed 's/$$.$$/\1\t/g' $1 n=$(expr $(head -n1$1|wc -c) \- 1);for i in $(seq 1$n);do echo "$t"|cut -f$i|tac|tr -d '\n';echo;done


Un-golfed:

t=$(sed 's/$$.$$/\1\t/g'$1) # Add a tab after every character.
n=$(expr$(head -n 1 $1 | wc -c) \- 1) # Count the number of characters in a row. for i in$(seq 1 $n); do # For each row. echo "$t"|cut -f "\$i" |tac|tr -d '\n' # Cut the i^th column, print, reverse and delete newline.
echo # Finished processing i^th row. Emit newline.
done


# JavaScript (ES6), 83

f=(s,o=[],a='')=>/./.test(s)?f(s.replace(/^./gm,x=>(a=x+a)&&''),[...o,a]):o.join\n

G.onclick=g=>X.innerHTML=f(X.innerHTML)
textarea{
height:100px;
line-height:7px;
}
<button id=G>Rotate</button>
<textarea id=X>
#
# #
#   #
#     #
#       #
#         #
#       #
#     #
#   #
# #
#
</textarea>