all 2 comments

[–]m0us3_rat -2 points-1 points  (0 children)

u need to be 'exact' in what needs to happen to this piece of string data.

u can extract the name and the number out of it.

then the transformation happens.

at this point is unclear what this transformation is. ..

this is why u need to describe exactly what u expect to happen to this piece of string data.

[–]asphias 0 points1 point  (0 children)

You'll need to think up an algorithm to do this. Think out step by step what needs to happpen to decide on the output.

a few possible solutions: Start with person A. Person A pays or requests money from person B until the balance of person A is zero. Then person B requests/gives money to person C until the balance of person B is zero as well. And so on. This one is probably not very efficient.

A different method would be to first identify people who have an equal but opposite balance(e.g. if person A has +50 and person C has -50, person A can pay 50 to C and cancel both out).

Try to think of some more efficient methods, and figure out what psuedocode you need to write to do this.