-4
\$\begingroup\$

The title is pretty self-explanatory, isn't it?

Your task is to output the alphabet (the string "abcdefghijklmnopqrstuvwxyz") to STDOUT, using each and every letter of the alphabet in your program once and only once.

Oh, and for a bit of extra fun?

The letters "g", "o", "l" and "f" must be in order (just for the code to be a bit more code-y).

Rules:

  • Only standard letters of the alphabet from ASCII count as letters (ë != e).
  • Both uppercase and lowercase characters count as letters (if you have E, you are not allowed to have e).
  • You are allowed to use comments, but every character in the comment is equal to 2 bytes.
  • Your final score will be the byte-count of your program, subtracted by 26.

This is code-golf, so shortest code in bytes wins.

\$\endgroup\$
17
  • \$\begingroup\$ May I take any input? \$\endgroup\$
    – Leaky Nun
    May 21, 2016 at 4:53
  • \$\begingroup\$ @KennyLau Why would you want to take input? But, yes if you want. \$\endgroup\$
    – clismique
    May 21, 2016 at 4:55
  • \$\begingroup\$ I didn't think the question through, did I? \$\endgroup\$
    – clismique
    May 21, 2016 at 4:55
  • \$\begingroup\$ I downvoted because it is too straight-forward. \$\endgroup\$
    – Leaky Nun
    May 21, 2016 at 4:57
  • 10
    \$\begingroup\$ Why the arbitrary "one answer per person" rule? \$\endgroup\$
    – Doorknob
    May 21, 2016 at 14:02

13 Answers 13

10
\$\begingroup\$

05AB1E, 27 26 - 26 = 0 bytes

Thanks to Katenkyo for saving 1 byte :). Code:

golfAqbcdehijkmnprstuvwxyz

Try it online!.

\$\endgroup\$
5
  • \$\begingroup\$ How does this work? \$\endgroup\$
    – DJMcMayhem
    May 21, 2016 at 15:35
  • \$\begingroup\$ @DrGreenEggsandHamDJ The golf part is just a bunch of no-ops. The A pushes the lowercase alphabet and the q after that quits the program, which then implicitly prints the lowercase alphabet. \$\endgroup\$
    – Adnan
    May 21, 2016 at 15:37
  • \$\begingroup\$ "Both uppercase and lowercase characters count as letters (if you have E, you are not allowed to have e)." so you can technically use golfAqbcdehijkmnprstuvwxyz which scores 0 :) \$\endgroup\$
    – Katenkyo
    May 23, 2016 at 9:11
  • \$\begingroup\$ @Katenkyo Thanks :), updated. \$\endgroup\$
    – Adnan
    May 23, 2016 at 9:16
  • 1
    \$\begingroup\$ Faster code (from what I've read): Aqgolfbcdehijkmnprstuvwxyz \$\endgroup\$ May 27, 2016 at 15:24
5
\$\begingroup\$

Brainfuck, 67 - 26 + 26 (comment) = 41 67 bytes

golfabcdehijkmnpqrstuvwxyz++++++++[>++++++++++++>+++<<-]>>++[-<+.>]

Try it online!

\$\endgroup\$
5
  • 4
    \$\begingroup\$ I think that the golfabcdehijkmnpqrstuvwxyz part is a comment! \$\endgroup\$ May 21, 2016 at 21:24
  • 4
    \$\begingroup\$ There's a slight difference between a no-op and a comment... \$\endgroup\$
    – Leaky Nun
    May 22, 2016 at 1:18
  • 3
    \$\begingroup\$ +- or <> would be a no-op. Characters not in the brainfuck alphabet are comments. \$\endgroup\$ May 22, 2016 at 2:24
  • 1
    \$\begingroup\$ Actually, you would need to add 52 bytes to your score, as each comment character counts twice. \$\endgroup\$ May 22, 2016 at 19:08
  • \$\begingroup\$ Count twice, and then minus 26, which is the same as what we have now. \$\endgroup\$
    – Leaky Nun
    May 22, 2016 at 22:44
3
\$\begingroup\$

Jolf, 27 - 26 = 1 byte

goΔaplfbcdehijkmnqrstuvwxyz

o assigns Δ to apl, which alerts pl, which is the lowercase alphabet. I take it that "in order" does not mean "adjacent to". You can see that f follows l which follows o which follows g. Try it out here!

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

Batch, 36 + 13 + 9 - 26 = 32 bytes

:g
@echo ab%0pqrstuvwxyz
:lfdijkmn

Requires that the batch file itself be named cdefghijklmno. Scored as 36 (size of file cdefghijklmno) + 13 (size of filename cdefghijklmno) + 9 (commented letters) - 26.

Edit: Saved 29 bytes even under my scoring scheme thanks to @ΈρικΚωνσταντόπουλος.

\$\endgroup\$
11
  • \$\begingroup\$ If I do not miscomprehend, your task is to output "abcdefghijklmnopqrstuvwxyz" to STDOUT. \$\endgroup\$
    – Leaky Nun
    May 21, 2016 at 10:32
  • \$\begingroup\$ @KennyLau Sorry I misunderstood the question. Let me think about it. \$\endgroup\$
    – Neil
    May 21, 2016 at 10:41
  • \$\begingroup\$ Read the rules again, please. You will delete this answer out of shame. \$\endgroup\$ May 26, 2016 at 12:25
  • \$\begingroup\$ @ΈρικΚωνσταντόπουλος I'll be in good company! \$\endgroup\$
    – Neil
    May 26, 2016 at 18:40
  • \$\begingroup\$ They're not comments, they're labels, so I think you don't have to count comment characters. \$\endgroup\$ May 27, 2016 at 15:09
2
\$\begingroup\$

CJam, 29 - 26 = 3 bytes

"golfabcdehijkmnpqrstuvwxyz"$

Try it online!

\$\endgroup\$
2
\$\begingroup\$

MATL, 29-26 = 3 bytes

'abcdehijkmnpqrstuvwxyzgolf'S

Try it Online!

\$\endgroup\$
2
\$\begingroup\$

Pyke, 29 - 26 = 3 bytes

"golfabcdehijkmnpqrstuvwxyz"S
\$\endgroup\$
2
\$\begingroup\$

J, 36 - 26 = 10 bytes

'golfabcdehjkmnpqrstvwxyz']u:97+i.26

Not a comment, just a string that's discarded. u: converts numbers to ASCII chars, and 97+i.26 is a range from 0..25 with vectorized addition over 97, the char code of a. Here's an alternative (albeit longer) solution using a.:

'golfbcdehjkmnpqrstvwxyz']a.{~97+i.26
\$\endgroup\$
2
\$\begingroup\$

dc, 111 - 26 = 85 bytes

[gol][P]s@[abcdef]1 1=@103 1 1=@[hijk]1 1=@108 1 1=@[mn]1 1=@111
1 1=@112 1 1=@[qr]1 1=@115 1 1=@[tuvwxyz]1 1=@

Run: dc -f alphabet_letters.dc

Output:

abcdefghijklmnopqrstuvwxyz

I use 1 1=@ as a trick to simulate l@x, that executes the print command P stored in register @. This is one example of a language that entailed a non-trivial solution for this task.

\$\endgroup\$
4
  • \$\begingroup\$ The output is supposed to be the alphabet in, er, alphabetical order. \$\endgroup\$
    – Jordan
    Aug 29, 2016 at 4:46
  • \$\begingroup\$ @Jordan I wasn't sure, because the statement said that the g, o, l and f letters must be in order so I thought the rest could be in any order. I'll correct my entry. \$\endgroup\$
    – seshoumara
    Aug 29, 2016 at 6:17
  • \$\begingroup\$ I believe OP intends for the output to be abcdefghijklmnopqrstuvwxyz, and for the g, o l, and f letters to be in that order in the source code, not the output. \$\endgroup\$
    – Jordan
    Aug 29, 2016 at 12:35
  • \$\begingroup\$ @Jordan thanks for clarifying things up for me. My updated answer should be correct now. \$\endgroup\$
    – seshoumara
    Aug 29, 2016 at 14:09
1
\$\begingroup\$

Actually, 29 - 26 = 3 bytes

"golfabcdehijkmnpqrstuvwxyz"S

Try it online!

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

Jelly, 29 - 26 = 3 bytes

“golfabcdehijkmnpqrstuvwxyz”Ṣ

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Dammit, Kenny... all the good solutions, gone like that. \$\endgroup\$
    – clismique
    May 21, 2016 at 4:53
  • \$\begingroup\$ What encoding are you using? I see some non-ascii characters. \$\endgroup\$ May 23, 2016 at 13:25
  • \$\begingroup\$ Updated, thanks for reminding. \$\endgroup\$
    – Leaky Nun
    May 23, 2016 at 13:26
1
\$\begingroup\$

Ruby, 57 37 47 - 26 = 21 bytes

I'm ashamed it took me that many tries to arrive at this super obvious solution.

"gol";$><<"abcdef\147hijk\154mnp\157qrstuvwxyz"

See it on ideone: http://ideone.com/FAtiy3

\$\endgroup\$
0
\$\begingroup\$

SmileBASIC, 68 61 bytes -26 = 35

_=97@V?CHR$(_);
_=_+1GOSUB"@"+KEY(3)[2]*(_<123)@ADLIJFMNPQTWXZ

Explained:

_=97 'set variable _ to 97 (ascii value of "a")
@V 'label
 ?CHR$(_) 'convert _ to a character and print
 _=_+1 'add 1 to _
GOSUB"@"+KEY(3)[2]*(_<123) 'jump to @V (KEY(3) is "SAVE") if _ is less than 123 (ascii code for z +1)
@ADLIJFMNPQTWXZ 'create a label with the unused letters
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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