Ruby (40 characters)
Interpret a string of a-z letters as a number in base 26, with a = 1, b = 2,
..., z = 26.
So "password" can be thought of as the number N =
16*(26**7) +
1*(26**6) +
19*(26**5) +
19*(26**4) +
23*(26**3) +
15*(26**2) +
18*(26**1) +
4*(26**0)
If we let s = "a"
(that is: 1) and we make (N-1) calls to s.succ!
, s will be "password"
(N). In other words, N = 1 + (N-1).
For an example that will run more quickly, to prove the calculation of N is correct, consider "pass"
as the target, where N is
16*(26**3) +
1*(26**2) +
19*(26**1) +
19*(26**0)
and
s = "a"
(N-1).times { s.succ! }
puts s #== "pass"
Since we want to print "a"
too, we need
s = "`"
N.times { print(s.succ! + " ") }
So back to the full "password". N = 129052722140
, leaving:
s=?`;0x1e0c2443dc.times{$><<s.succ!+" "}
I hunted for a more compact form of 129052722140 == 0x1e0c2443db
but couldn't find one.
(Updated to fix the lack of printing "a"
, thanks to Cary.)