Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Golf: Movie style code cracker.

by w-ber (Hermit)
on Sep 12, 2008 at 20:44 UTC ( #711005=note: print w/ replies, xml ) Need Help??


in reply to Golf: Movie style code cracker.

124 characters, with the following features:

  • Digits are displayed on a single line instead of scrolling the screen. (Tested only on Linux with bash.)
  • Execution takes anything between $D and $D*10 seconds to run, when using base 10. Thus, if $D == 10, the program may run for as long as 100 seconds or 1 m 40 s. $D == 15 will break the "bonus barrier".
perl -e'$|++;split//,int rand 10**pop;sub f{$.=++$.%10;print$.;sleep 1 +,print"\b";$.==$_[0]||&f;print shift;@_&& &f}&f;print"\n"' 10

You may additionally add ."\a" after print shift to produce a bell sound after a digit has been successfully found. That increases character count to 129.

The OP is ambiguous, though. It says pick a number between 0 and 1e$D-1, but doesn't say whether it should contain prefix zeroes or not. My code doesn't produce prefix zeroes.

--
say "Just Another Perl Hacker";


Comment on Re: Golf: Movie style code cracker.
Select or Download Code
Re^2: Golf: Movie style code cracker.
by BrowserUk (Pope) on Sep 14, 2008 at 03:44 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://711005]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2014-07-10 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (216 votes), past polls