Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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...

-><- -><- -><- -><- -><-
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
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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2016-04-29 05:35 GMT
Find Nodes?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW

    Results (438 votes). Check out past polls.