Let's say
A pays £10 for court for four people including himself (So £2.50 each)
P pays £10 for a court for four people including himself. (So £2.50 each)
That’s equivalent to A lending £2.50 to three people.
And P lending £2.50 to three people.
So that leads to what is mentioned at the beginning of the question
"A" needs \$2.50 from D,G,P
"P" needs \$2.50 from A,D,G
If you’re not A or P, you owe £5
If you’re A or P, you owe £2.50 (and others owe you 3*£2.50)
Everybody ends up paying £5 . i.e. -£5
A -£10
P -£10
D 0
G 0
D pays £5 to A
(which actually makes it easier, it could have been unintentional e.g. D thought "A" was going to book both courts, or it could have been intentional, just paying all that is owed and let the others figure it out, he's done his bit)
D only owes A £5 so it was too much , to A, but actually made it much easier
A -£5
P -£10
D -£5
G 0
Then if G pays P £5
A -£5
P -£5
D -£5
G -£5
Or to put it another way, a in table all in one go. and one can add a middle column showing how much needs to be added or subtracted..
A -10 | +5 | -5
P -10 | +5 | -5
D 0 | -5 | -5
G 0 | -5 | -5
It shows that D pays 5 and G pays 5. It doesn't show who D paid (whether it was A or P), or who G paid (whether A or P), but that's fine, it doesn't matter. It works regardless
So that table does it in one.
The other route seems to be long.. and didn't make it obvious that D or G should pay £5 to one person to make things easier.
D-----2.50-------A
G-----2.50-------A
P-----2.50-------A
A-----2.50------P
G-----2.50-----P
D-----2.50----P
simplify it..
e.g. identify chains or ones that can cancel out.
D-----2.50-------A A-----2.50------P P-----2.50-------A
G-----2.50-------A
G-----2.50-----P
D-----2.50----P
becomes
D-----2.50------A
G-----2.50-------A
G-----2.50-----P
D-----2.50----P
suppose D pays £5 to A
A----2.50-----D
G-----2.50-------A
G-----2.50-----P
D-----2.50----P
simplify
A----2.50-----D D-----2.50----P
G-----2.50-------A
G-----2.50-----P
becomes
A--2.50---P
G-----2.50-------A
G-----2.50-----P
becomes
G-----2.50-------A A--2.50---P
G-----2.50-----P
becomes
G----2.50---P
G---2.50--P
becomes
G---£5---P
So G must pay P £5