Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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


Comment on Re: (GOLF) pearls and perl
Download Code
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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-12-25 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls