I wouldn’t look at anyone else’s code to help them until my work was complete. The person struggling can’t see another’s code. That’s what I take from both snippets above. Two struggling students shouldn’t help each other debug.
I do agree that they were likely caught by a plagiarism checker.