|Just another Perl shrine|
Re: Golf: Movie style code cracker.by betterworld (Curate)
|on Sep 14, 2008 at 19:34 UTC||Need Help??|
This runs about 4 minutes for a 10 digit code. Change 1e-5 to 1e-4 if you want it to finish in 25 seconds.
Actually you can replace ($_=reverse)++ with $_++, which would reduce the length to 93 characters, but then the first digits will spin awfully slow (for a 10 digit code), and they will probably end up as ones.
Update: Adopted the required counting method, thus I have 108 characters, not 103.
Update 2: New version with 71 characters (however it would be a few (about 4) characters more if I hadn't copied a trick from BrowserUk; I'll elaborate in the spoiler tag):
Caveat: The second version will probably not terminate for a 1-digit code.
Update 3: :-( I just noticed that my 71 character solution has the problem that it always prints "8" as the last digit. For the moment, I offer the following fix, which makes it 75 characters long (and I'll omit the spoiler tags as the contest seems to be over):
(And you can modify the 1e6 constant to shorten the runtime.)