Yes, people can cheat. In my example, you can mitigate by having them also do a live presentation and ask probing questions about what they've written if that's part of the job.
The coding equivalent would be asking them why they took some specific approach or used a particular algorithm. I'm not sure about my feelings with respect to coding takehomes but there are circumstances where someone doesn't have an openly viewable body of work where takehomes can make sense.