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.
-
7\$\begingroup\$ Any special reason for the "including length of language name"? \$\endgroup\$Victor Stafusa– Victor Stafusa2014年02月05日 21:56:40 +00:00Commented Feb 5, 2014 at 21:56
-
1\$\begingroup\$ Are input lines equal length (padded with spaces if necessary)? \$\endgroup\$mattnewport– mattnewport2014年02月05日 22:04:44 +00:00Commented Feb 5, 2014 at 22:04
-
1\$\begingroup\$ @nbubis Don't think that this is really such a incentive. \$\endgroup\$Victor Stafusa– Victor Stafusa2014年02月05日 22:10:44 +00:00Commented Feb 5, 2014 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– Peter Taylor2014年02月05日 23:39:19 +00:00Commented Feb 5, 2014 at 23:39
-
15\$\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– Doorknob2014年02月06日 01:36:04 +00:00Commented Feb 6, 2014 at 1:36
11 Answers 11
K, 1+1
+
.
k)+("# # #";" # # ";"#####")
"# #"
" ##"
"# #"
" ##"
"# #"
-
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– CousinCocaine2014年07月04日 10:54:56 +00:00Commented Jul 4, 2014 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– tmartin2014年07月04日 15:34:32 +00:00Commented Jul 4, 2014 at 15:34
GolfScript (10 chars + 10)
n/zip-1%n*
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.
-
\$\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– Tomas2014年02月06日 11:55:49 +00:00Commented Feb 6, 2014 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'))))
# # #
# #
#####
# #
##
# #
##
# #
# ## # #
## # #
# ######
##
# #
-
\$\begingroup\$ A bit late, but aren't you supposed to add 6 chars because "Python" has six letters? \$\endgroup\$Erik the Outgolfer– Erik the Outgolfer2016年11月01日 17:18:21 +00:00Commented Nov 1, 2016 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.
-
\$\begingroup\$ The score is 5: 4 + 1 (the length of
R
) \$\endgroup\$TuxCrafting– TuxCrafting2016年09月13日 21:12:55 +00:00Commented Sep 13, 2016 at 21:12
Ruby 56
s=[*$<];s[0].size.downto(1){|i|puts s.map{|l|l[i-1]}*''}
-
\$\begingroup\$ I think there's a syntax error somewhere. \$\endgroup\$Nathaniel Bubis– Nathaniel Bubis2014年02月05日 23:58:27 +00:00Commented Feb 5, 2014 at 23:58
-
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
# #
##
# #
##
# #
-
\$\begingroup\$ Basically a duplicate of codegolf.stackexchange.com/a/20157/20356 \$\endgroup\$seequ– seequ2014年07月07日 09:32:51 +00:00Commented Jul 7, 2014 at 9:32
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>