Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: (Golf) Minimizing the Bacon Number

by MeowChow (Vicar)
on May 15, 2001 at 05:16 UTC ( #80424=note: print w/ replies, xml ) Need Help??


in reply to (Golf) Minimizing the Bacon Number

Here's a solution (plus extra credit :) at 151:

sub bacon { (%g,%d)=@_;for$k(keys%g){($i,@l,%v)=(0,$k);{!$v{$_}++and$d{$k}+=$i f +or@l;$i++;(@l=map{grep!$v{$_},@{$g{$_}}}@l)&&redo}}(sort{$d{$a}<=>$d{ +$b}}keys%d)[0] }
It runs in O(n^2).
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print


Comment on Re: (Golf) Minimizing the Bacon Number
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (18)
As of 2015-07-06 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (75 votes), past polls