I've told this story before, but... why not. I used to do my homework with my buddy. We would not copy each other's stuff, but we'd bounce ideas around: "hmm, this problem sort of looks like this thing", and "I'm trying to decide between these two data structures". That kind of stuff. You know, actually learning by thinking things through out loud and considering alternatives.
We had one class with an archetypically CompSci homework assignment, like "simulate a telephone switchboard with M operators, N callers, and X extensions". We each started off with boilerplate like "int operators, callers, extensions", etc., and went from there. When we were finished, we had written the exact same program. I mean, same variables, same functions, same indentation, everything. Probably not surprising given that we'd been doing this for a couple of years by that point, but still.
Fortunately, we had an awesome professor who knew both of us well. He called us each in separately (without saying why) to ask us how our program worked, why we'd made the design choices, and so on - basically interrogating us to see whether we'd actually done the work ourselves. Then he brought us in together, showed us each other's assignments, and watched us stammer in confused terror before he broke down laughing.
That could have gone very, very badly. We didn't cheat in any sense of the word, but it definitely would have looked like it to anyone else.