Hi I need some help with the following scenario in php. I have a db with users every user has an ID, have_card and want_card. I know how to make a direct match (one user trades with another user). But if there is no direct match but there is a circular swap like:
User #1 has card A wants card B
User #2 has card B wants card C
User #3 has card C wants card A
In this scenario there is no direct match between two users. But if:
User #1 gives his card to User #3
User #3 gives his card to User #2
User #2 gives his card to User #1
Every ones happy.
All the info I have to start with is User #1 how do I find User #2 and User #3?
Thanks to everyone for your answers.