2
\$\begingroup\$

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.

\$\endgroup\$

closed as unclear what you're asking by 12Me21, Wheat Wizard, Xcali, caird coinheringaahing, FantaC Mar 27 '18 at 19:10

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 7
    \$\begingroup\$ Any special reason for the "including length of language name"? \$\endgroup\$ – Victor Stafusa Feb 5 '14 at 21:56
  • 1
    \$\begingroup\$ Are input lines equal length (padded with spaces if necessary)? \$\endgroup\$ – mattnewport Feb 5 '14 at 22:04
  • 1
    \$\begingroup\$ @nbubis Don't think that this is really such a incentive. \$\endgroup\$ – Victor Stafusa Feb 5 '14 at 22:10
  • 5
    \$\begingroup\$ 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. \$\endgroup\$ – Peter Taylor Feb 5 '14 at 23:39
  • 14
    \$\begingroup\$ 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... \$\endgroup\$ – Doorknob Feb 6 '14 at 1:36

11 Answers 11

10
\$\begingroup\$

K, 1+1

+

.

k)+("# # #";" # # ";"#####")
"# #"
" ##"
"# #"
" ##"
"# #"
\$\endgroup\$
  • 2
    \$\begingroup\$ 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 \$\endgroup\$ – CousinCocaine Jul 4 '14 at 10:54
  • 7
    \$\begingroup\$ The k) is just a prompt, like >>> in a python interpreter. It doesn't need to be there at all \$\endgroup\$ – tmartin Jul 4 '14 at 15:34
4
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Tomas Feb 6 '14 at 11:55
4
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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'))))
# # #
 # # 
#####
# #  
 ##  
# #  
 ##  
# #  
# ## # #
 ## # # 
# ######
 ##     
# #     
\$\endgroup\$
  • \$\begingroup\$ A bit late, but aren't you supposed to add 6 chars because "Python" has six letters? \$\endgroup\$ – Erik the Outgolfer Nov 1 '16 at 17:18
2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ The score is 5: 4 + 1 (the length of R) \$\endgroup\$ – TuxCrafting Sep 13 '16 at 21:12
1
\$\begingroup\$

Ruby 56

s=[*$<];s[0].size.downto(1){|i|puts s.map{|l|l[i-1]}*''}
\$\endgroup\$
  • \$\begingroup\$ I think there's a syntax error somewhere. \$\endgroup\$ – nbubis Feb 5 '14 at 23:58
  • \$\begingroup\$ @nbubis All lines must be of the same length (padded with spaces). Also an updated version of Ruby is probably required. \$\endgroup\$ – daniero Feb 6 '14 at 0:03
1
\$\begingroup\$

Perl, 44 chars

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

Assuming all rows have equal length.

\$\endgroup\$
1
\$\begingroup\$

J (4+1)

|:|.

Expected input as a string matrix. Usage:

   a=: >'# # #';' # #';'#####'
   a
# # #
 # # 
#####
   |:|.a
# #
## 
# #
## 
# #
\$\endgroup\$
1
\$\begingroup\$

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

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>

\$\endgroup\$

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