http://www.perlmonks.org?node_id=644868

Melly has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monkeys,

This isn't really a perl question (although I'll be coding in perl), but please bestow your wisdom on this poor benighted traveller...

I've given myself a little fun project of writing a facebook app - what I want to do is to try and find a "circle of friends" - i.e. starting from myself, find a pathway back to myself. For example, if I am "A", and I have two friends "B" and "D", and "C" is not a friend of mine, but is a friend of "B" and "D", then a valid circle would be: A->B->C->D->A (as an extra note, this circle would not be valid if "B" and "D" are friends, since "A" would then be superfluous to the circle).

Anyways, I've got some rules to implement, but the basic question is what would be the best general algorithm to use in this case? The A* algorithm looks possible, but I'd be interested to hear alternative suggestions.

Thanks, and sorry for the OT post.

map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
Tom Melly, pm (at) cursingmaggot (stop) co (stop) uk