good chemistry is complicated,and a little bit messy -LW PerlMonks

Re: (GOLF) pearls and perl

by jwest (Friar)
 on Apr 04, 2002 at 16:04 UTC ( #156695=note: print w/replies, xml ) Need Help??

in reply to (GOLF) pearls and perl

My first round of golf, so be gentle... I took a slightly different route to get to the same solution:

```use strict;
my @p = (1,1,1,1,1,1,1,1,2,1,1,1);
print perl(),"\n";

sub perl{sub w{my\$h=int((\$_[1]-\$_[0])/2+\$_[0]);\$"='+';my\$o=eval"@p[\$_[
+0]..\$h]";
my\$t=eval"@p[\$h+1..\$_[1]]";\$o<=>\$t?((\$o<=>\$t)==1?(\$_[0],\$h):(\$h+1,\$_[1
+])):undef;}
my@r=w(w(0,11));my\$v=\$p[\$r[0]]<=>\$p[\$r[0]+1];\$v?(\$v==1?\$r[0]:\$r[0]+1):
+\$r[1];}

I count this at 237 characters. Hopefully I haven't violated any of the rules...

--jwest
```-><- -><- -><- -><- -><-
All things are Perfect
To every last Flaw
And bound in accord
With Eris's Law
- HBT; The Book of Advice, 1:7
```

Replies are listed 'Best First'.
Re: Re: (GOLF) pearls and perl
by thraxil (Prior) on Apr 04, 2002 at 16:57 UTC

well, it doesn't return anything when the pearl is lighter and it doesn't return whether the pearl found is heavier or lighter. good try though. i'm still examining the code trying to figure out if your overriding of the weighing breaks any rules.

anders pearson

Create A New User
Node Status?
node history
Node Type: note [id://156695]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2018-02-18 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When it is dark outside I am happiest to see ...

Results (257 votes). Check out past polls.

Notices?