Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: (Golf) Minimizing the Bacon Number

by no_slogan (Deacon)
on May 15, 2001 at 06:07 UTC ( #80433=note: print w/replies, xml ) Need Help??

in reply to (Golf) Minimizing the Bacon Number

Down to 97 characters. Works for arbitrary graphs, i think.
sub b { $a=@_*@_;for(@_){%t=@_;$t=@r=$_;$t+=%t while@r=map@{delete$t{$_}},@r;$ +a=$t,$b=$_ if!ref&&$t<$a}$b }

Update: Thanks to MeowChow for crawling through that thoroughly fetid blob of code and discovering that I need to say $t+=keys%t instead of $t+=%t. And here I thought I was being so clever.

Replies are listed 'Best First'.
Re: Re: (Golf) Minimizing the Bacon Number
by MeowChow (Vicar) on May 15, 2001 at 07:14 UTC
    Interestingly, this causes both my 5.6 Win32 ActiveState Perl and my 5.6.1 Linux to segfault, but appears to work under 5.00503. Hmmm....

    update: I think this is a garbage-collection issue, stemming from your deletion of a hash key will simultaneously dereferencing it. Ingenious, and dangerous.

    update2: Err, that wasn't the problem, the problem was that my test hash was already %t, so it was getting reset inside the sub, and I ran into this.

                   s aamecha.s a..a\u$&owag.print

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://80433]
LanX .oO( But what if the nuclears codes don't fit into 140 characters ??? o_O )

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-01-20 15:20 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (174 votes). Check out past polls.