Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Golf: Movie style code cracker.

by vrk (Chaplain)
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";

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://711005]
[erix]: heh

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2018-04-25 17:18 GMT
Find Nodes?
    Voting Booth?