It's really easy to detect duplicate programs. I've failed multiple students due to cheating on assignments. Code obfuscation is incredibly easy to detect using something like MOSS .
Yea, I've had this happen to me in my first year of university. Wrote an assignment and foolishly put it on a public Github repo. Someone found it, changed a few variable names and submitted it. Got caught by an auto-detector and accused of plagiarism, luckily the prof just gave me a 0 on the assignment.