Rotate simple ASCII art

2

1

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.

nbubis

Posted 2014-02-05T21:53:05.080

Reputation: 1 019

Question was closed 2018-03-27T19:10:36.860

7Any special reason for the "including length of language name"? – Victor Stafusa – 2014-02-05T21:56:40.287

@Victor - to encourage users of non esoteric languages to compete as well. – nbubis – 2014-02-05T21:59:57.363

1Are input lines equal length (padded with spaces if necessary)? – mattnewport – 2014-02-05T22:04:44.590

1@nbubis Don't think that this is really such a incentive. – Victor Stafusa – 2014-02-05T22:10:44.077

@Victor - yes you're right :( how do you suggest penalizing esoterics without specifying languages? – nbubis – 2014-02-05T22:49:19.833

1@nbubis By asking problems that are very hard or impossible to solve in esoteric languages. Very few esoteric languages features graphics, animations, networking and mouse or touchscreen input, so this could be a way to do it. – Victor Stafusa – 2014-02-05T23:21:33.273

5Why 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. – Peter Taylor – 2014-02-05T23:39:19.413

14So, 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 – 2014-02-06T01:36:04.120

1

nbubis I understand you, because the esoteric languages can be demotivating, but we should try to find better criteria for handling that

– Tomas – 2014-02-06T11:33:15.523

Answers

10

K, 1+1

+

.

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

tmartin

Posted 2014-02-05T21:53:05.080

Reputation: 3 917

2I 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 – CousinCocaine – 2014-07-04T10:54:56.553

7The k) is just a prompt, like >>> in a python interpreter. It doesn't need to be there at all – tmartin – 2014-07-04T15:34:32.600

4

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.

Peter Taylor

Posted 2014-02-05T21:53:05.080

Reputation: 41 901

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. – Tomas – 2014-02-06T11:55:49.953

4

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.

lukass

Posted 2014-02-05T21:53:05.080

Reputation: 71

3

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.

Gareth

Posted 2014-02-05T21:53:05.080

Reputation: 11 678

3

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'))))
# # #
 # # 
#####
# #  
 ##  
# #  
 ##  
# #  
# ## # #
 ## # # 
# ######
 ##     
# #     

Abhijit

Posted 2014-02-05T21:53:05.080

Reputation: 2 841

A bit late, but aren't you supposed to add 6 chars because "Python" has six letters? – Erik the Outgolfer – 2016-11-01T17:18:21.173

2

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.

CousinCocaine

Posted 2014-02-05T21:53:05.080

Reputation: 1 572

The score is 5: 4 + 1 (the length of R) – TuxCrafting – 2016-09-13T21:12:55.627

1

Ruby 56

s=[*$<];s[0].size.downto(1){|i|puts s.map{|l|l[i-1]}*''}

daniero

Posted 2014-02-05T21:53:05.080

Reputation: 17 193

I think there's a syntax error somewhere. – nbubis – 2014-02-05T23:58:27.983

@nbubis All lines must be of the same length (padded with spaces). Also an updated version of Ruby is probably required.

– daniero – 2014-02-06T00:03:12.317

1

Perl, 44 chars

$/=$i--;$_=<>;say/(.).{$i}$/gmwhile!++$i||$1

Assuming all rows have equal length.

Tomas

Posted 2014-02-05T21:53:05.080

Reputation: 2 333

1

J (4+1)

|:|.

Expected input as a string matrix. Usage:

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

ɐɔıʇǝɥʇuʎs

Posted 2014-02-05T21:53:05.080

Reputation: 4 449

Basically a duplicate of http://codegolf.stackexchange.com/a/20157/20356

– seequ – 2014-07-07T09:32:51.550

1

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

Yeow_Meng

Posted 2014-02-05T21:53:05.080

Reputation: 341

0

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>

Washington Guedes

Posted 2014-02-05T21:53:05.080

Reputation: 549