views:

140

answers:

1

Hello all,

Let's say there are N people and all these people have 1 basket and unlimited balls. They can throw a ball to others' baskets.

We let them throw their balls to others' baskets and we come up with a scenario like that :

'A' person's basket Balls from E, F, G, I, K, L, M, P

'B' person's basket Balls from A, C, E, F, K, T, R, Z

'C' person's basket Balls from ......

etc...

so I want to design an algorithm to find out which ones are friends. For example if A, C, D and E are friends they should throw their balls to each others' baskets. But at the same time they can throw some random stranger's basket too.

I know it is an optimization problem, there is not a spesific solution but I'm open to any idea to start over.

Thanks.

+1  A: 

Friends will probably give each other a ball - there's a great starting point.

for x,y in people:
    if (x contains y && y contains x):
        x & y are friends.
    else:
        skip.

Rough pseudocode, write it in what you know.

That's only the beginning though, you should probably look at clusters of friends to weed out coincidences and add in forgotten friends.

mr1989foster