37
\$\begingroup\$

The program must print the alphabet four times: first in the normal alphabetical order, second in the order of a qwerty keyboard, third in the order of a dvorak keyboard, and lastly in reverse alphabetical order. The output should resemble this:

abcdefghijklmnopqrstuvwxyz
qwertyuiopasdfghjklzxcvbnm
pyfgcrlaoeuidhtnsqjkxbmwvz
zyxwvutsrqponmlkjihgfedcba

The output is not case-sensitive, and you can add or omit newlines or spaces wherever you wish.

The catch: the program must be less than 104 characters, or, in other words, smaller than the length of the alphabet times four.

I will accept the answer with the shortest code, unless I see something really clever or interesting that I am more impressed with.

EDIT: I will accept the shortest answer on Wednesday, 4/27/2011.

EDIT2: And the winner is (as usual) Golfscript in 64 chars! Second place, which is behind by only three chars, is also in Golfscript, with 67 chars, followed by Bash in third place with 72 chars.

But there were a few others I wanted to mention, such as this one, which, depending on your definition, only used 52 "characters", and this one where he wrote it in a language he created.

There were a few people who broke an unwritten rule and did not qualify, but I will mention them just for their way of thinking without the box.

\$\endgroup\$
  • 11
    \$\begingroup\$ Consider using a bounty for an answer that impressed you. I think accepting an answer in a code-golf should always be the natural criterion (i.e. length). \$\endgroup\$ – Joey Apr 23 '11 at 16:00
  • \$\begingroup\$ I lost using Tcl: tio.run/… \$\endgroup\$ – sergiol Jul 25 '17 at 22:19

37 Answers 37

1
\$\begingroup\$

Deorst, 39 bytes

EfEuE|'pyfgcrlaoeuidhtnsqjkxbmwvz'EfVE;

Try it online!

How on Earth is Deorst beating everything bar Jelly???

How it works

Ef             - Push the lowercase alphabet
  EuE|         - Push 'qwerty…vbnm'
      '…'      - Push that string
         Ef    - Push the alphabet
           VE; - Reverse and concatenate
\$\endgroup\$
0
\$\begingroup\$

PHP - 45

I don't know if this is concidered cheating or not :)

<?=file_get_contents("http://goo.gl/dK17k");
\$\endgroup\$
  • \$\begingroup\$ Only solution of its kind! :D +1 \$\endgroup\$ – Ry- Apr 27 '11 at 4:31
  • \$\begingroup\$ @minitech: I posted a similar solution in Python, longer but with more correct output, before this. \$\endgroup\$ – jscs Apr 27 '11 at 20:16
  • \$\begingroup\$ Okay, upvoted also. But this is shorter. Also not sure how you can have "more" correct output (it is correct). \$\endgroup\$ – Ry- Apr 27 '11 at 21:00
  • \$\begingroup\$ @minitech: this prints the entire contents of the page, where mine prints only the requested output -- the four orderings of the alphabet. No big deal, though, it's all just for fun. Thanks for the upvote! :) \$\endgroup\$ – jscs Apr 28 '11 at 21:01
  • \$\begingroup\$ @minitech: my mistake; I assumed this was pointing to this page. Apologies to you and to Nicklas. \$\endgroup\$ – jscs Apr 28 '11 at 22:43
0
\$\begingroup\$

Bash, 109

a(){ printf "$@";}
v=`a "\%o" {97..122}`
a $v
a qwertyuiopasdfghjklzxcvbnmpyfgcrlaoeuidhtnsqjkxbmwvz
a $v|rev

Output:

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

Mouse-2002, 99 bytes

65i:(i.h.<^i.!'i.1+i:)"qwertyuiopasdfghjklzxcvbnmpyfgcrlaoeuidhtnsqjkxbmwvz"(i.64>^i.!'i.1-i:)

Self-explanatory.

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

RProgN, 62 Bytes Noncompeting

a S . "qwertyuiopasdfghjklzxcvbnmpyfgcrlaoeuidhtnsqjkxbmwvz" a

I'm a bit disappointed RProgN didn't exist at the time of this question. It could have won something!

Try it Online!

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

Scala, 128 Bytes

Not golfy enough, but readable :)

val l=("qwertyuiopasdfghjklzxcvbnm","pyfgcrlaoeuidhtnsqjkxbmwvz");List(l._1,l._1.sorted,l._2,l._2.sorted.reverse).mkString("\n")
\$\endgroup\$
0
\$\begingroup\$

Jelly, 25 bytes

Øa;Øq;“¡®×Ṫ}Ƭ#Q>Ẉṛ’œ?$;Ṛ

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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