So, my take on this is to sit down with the student and have roughly this talk:
So, I'm a little disappointed by the lab you handed in, for two reasons. The first is that it is pushing on the edges of plagiarism. Now, I'm not going to go through the formal process, and there is going to be no punishment this time. I am instead assuming that this is a distinction that you were unaware of, and I am going to make sure that you are completely aware of it now:
Plagiarism means passing off someone else's work as your own, and this code isn't really your own, and your source isn't fully cited. As I said, I'm not going to pursue this further at this time, but in academic work, you should be citing sources for anything that is not entirely your own.
The second reason I'm disappointed is because you've even more deeply misunderstood the purpose of the assignment. You clearly came in thinking that the purpose here was to accomplish the task. I know that in industry, the idea is often to just get working code out. But in spite of what you might think, I actually care very little about [insert the result of the lab here, such as "the number of brick arrangements in this oddly-specified wall" or "whether the character in this game can correctly identify a collision"]. Why do you suppose I created this assignment? Was it because this is an unsolved puzzle, and there is a pressing need to accomplish this task?
Of course not! These problems have been solved many times before.
The purpose of the task is to help you learn and absorb the material, and to help make you a better student and a more capable person. The ideas in this lab are foundational, and carefully chosen to help you build up to bigger and more difficult ideas in the future. I want you to absorb these ideas well enough that you can mentally use them to build those bigger and more complex ideas. The goal was never this algorithm per se. The goal has always been mastery, so that you can move on to even bigger and better things with a good chance of success.
I think you can see where I'm going with this. You have kinda cheated me by giving in work that's only sort of your own, and you have kinda cheated yourself by only sort of wrestling with the topic well enough to master it.
We will survive this today, and we will move forward. But I need you to understand that this isn't the way to approach lab work. Can I now trust that I won't get this sort of work turned in again?
... and after the student agrees ...
Good. Labs are for learning. I hope that the rest of your day is pleasant. Take care, and I will see you again in class.