On site programming puzzles are flawed, yes, especially whiteboard programming (as interviewee you're stuck with still doing them, but there's things you can do to make it less awful: https://codewithoutrules.com/2016/04/04/interview-puzzles/)
Other alternatives:
1. Take-home programming exercise. More realistic, if it's a good task. Biased against people with less free time, though.
2. Paid take-home real work. DuckDuckGo does this, as does SpiderOak I think. Doesn't work well for people who have current job, but if it ever becomes popular it'll be easier for people to quit during job hunt period.
3. Pair programming during interview. Somewhat more realistic than whiteboard puzzle, biased against people with interview nerves.
4. Debugging code during interview. Somewhat more realistic than whiteboard puzzle, biased against people with interview nerves.
Etc..
There's no magic bullet, sadly.