Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Golf: Movie style code cracker.

by vrk (Chaplain)
on Sep 12, 2008 at 20:44 UTC ( [id://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";

Replies are listed 'Best First'.
Re^2: Golf: Movie style code cracker.
by BrowserUk (Patriarch) on Sep 14, 2008 at 03:44 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-19 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found