-4
\$\begingroup\$

You have to output the alphabet (upper case) with the shortest code possible.

Exact output expected : ABCDEFGHIJKLMNOPQRSTUVWXYZ

\$\endgroup\$
0

6 Answers 6

6
\$\begingroup\$

APL, 2 chars

⎕A

It's a constant string with the uppercase letters from A to Z

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

Python 35 chars

print("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
\$\endgroup\$
1
\$\begingroup\$

BASH 21 chars

echo {A..Z}|tr -d " "

Output:

~$ echo {A..Z}|tr -d " "
ABCDEFGHIJKLMNOPQRSTUVWXYZ
\$\endgroup\$
6
  • \$\begingroup\$ For a shorter way see the bash solution posted for this question's duplicate. \$\endgroup\$
    – manatwork
    Feb 5, 2014 at 12:35
  • \$\begingroup\$ Sure, but the Output has to be exactly in the form provided. The answer you linked to is in lowercase with spaces. But nevertheless thank you for pointing me there :) \$\endgroup\$
    – german_guy
    Feb 5, 2014 at 12:39
  • 1
    \$\begingroup\$ Interesting. printf %s {A..Z} gives me uppercase letters without any space. \$\endgroup\$
    – manatwork
    Feb 5, 2014 at 12:41
  • \$\begingroup\$ Hmmm, true. Maybe you could then just submit this as an answer \$\endgroup\$
    – german_guy
    Feb 5, 2014 at 12:43
  • 2
    \$\begingroup\$ Pointless. This question will be probably closed soon as duplicate. I only posted trying to help you get the taste of golfing. \$\endgroup\$
    – manatwork
    Feb 5, 2014 at 12:49
1
\$\begingroup\$

R, 19

cat(LETTERS,sep="")

Output:

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

Ruby 2.0.0, bytesize: 19:

=> p([*'A'..'Z'].join)
=> "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

update. this produce without quotes:

=> ruby -e '$><<[*?A..?Z].join'
=> ABCDEFGHIJKLMNOPQRSTUVWXYZ
\$\endgroup\$
2
  • \$\begingroup\$ You can use ?A and ?Z instead of 'A' and 'Z'. And you can use *'' instead of .join. And the parenthesis is not necessary there. Sadly this outputs the alphabet between double quotes. \$\endgroup\$
    – manatwork
    Feb 5, 2014 at 12:44
  • \$\begingroup\$ thanx @manatwork I'm surprised *''! \$\endgroup\$
    – user13426
    Feb 5, 2014 at 12:57
1
\$\begingroup\$

Delphi

52 bytes

var i:int16;begin for i:=65to 90do write(chr(i))end.

45 bytes

begin write('ABCDEFGHIJKLMNOPQRSTUVWXYZ');end.
\$\endgroup\$
4
  • \$\begingroup\$ You have to post a functional piece of code, including declarations and any other stuff required by the language. \$\endgroup\$
    – manatwork
    Feb 5, 2014 at 13:01
  • \$\begingroup\$ Edited it, I thought you just needed the required code to display it... my bad \$\endgroup\$
    – Teun Pronk
    Feb 5, 2014 at 13:06
  • \$\begingroup\$ Actually the program X; is not necessary and in this case byte is enough. Not mentioning that the variable declaration in the second version is pointless. \$\endgroup\$
    – manatwork
    Feb 5, 2014 at 13:19
  • \$\begingroup\$ sighs could get it shorter anyhow, just had something coming up all of a sudden, I will edit it soon.. \$\endgroup\$
    – Teun Pronk
    Feb 5, 2014 at 13:30

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