Write a program which performs brute force letter combination until the word "password" is found

Perl, 19 chars

say for a..password

Uses newlines as delimiters, per clarification above. Run with perl -M5.010 (or just perl -E 'say for a..password') to enable the Perl 5.10+ say feature. Per meta, this doesn't count as extra chars.

(If you insist on spaces as delimiters, $,=$";say a..password is only two chars longer. However, it's also very slow and wasteful of memory, to the point of being unusable in practice, since it tries to build the entire list in memory before printing it.)


Ruby, 33 chars (optimal but longer version)

?a.upto('password'){|c|$><<c+' '}

I like the 'a'.upto('password'); it tells you exactly what it's doing. Ruby is great and expressive like that. :D

Of course, print c,' ' would also be much clearer, but using $> is two characters shorter.

Ruby, 29 25 chars (slow version)

$><<[*?a..'password']*' '

This one's shorter, but it prints all of the tokens at once, so it takes a long, long time to run!


Perl, 33 32 24 characters

A solution in 32 characters:

$_=a;print$_++,$"until/passwore/

Not much to say about this one. I could reduce this to 27 characters if I could use newlines instead of spaces to separate the entries.

Ilmari Karonen points out that .. internally calls ++, so a better solution (25 characters) would be:

print$_,$"for a..password

By taking advantage of Perl's command-line options, here's an equivalent 24-character solution:

perl -l40e 'print for a..password'

The rules for counting perl flags is here, for those who aren't familiar with them.

Of course, Ilmari's 21-character solution is shorter still, but it requires a machine that can allocate an array of 129,052,722,140 strings.