Friend's Involvement in Plagiarism
I suggest a middle ground. Even granting that the facts are exactly as you stated, it seems to me that you don't know for sure what communication there was between A and B. A may have provided some sample code, intending that B would at least rewrite it. And, unlikely as it seems, B may have studied the code and rewritten it. So this could be a borderline case. Even if A complained to you that they had to "write B's assignment for them", that may have been an exaggeration.

So I suggest that you go to the professor and explain that you think that B had an excessive amount of help. Explain that someone was tutoring B, and may have crossed a line without intending to. I don't think you need to name A even if you are asked. And if the professor does find out who A is, well, professors are people too, and will probably exercise some judgement.

Of course, I'm not excusing what A or B did. I'm just pointing out that you don't know exactly what happened (even if you're sure you have the facts straight), so report what you know, but be careful not to overstate it.