Many moons ago when I was doing coding jobs I had a series of interviews that required me to code stuff to demonstrate what I knew. I was looking to move away from my current job into new areas and didn't know how they worked but they all seemed to ask the same thing
1) Code something
2) Take a coding test
What I learnt very quickly was that lots of people are really looking to hire people not quite as smart as they are. I knew this because I had three interviews where the following happened
Interview 1:
Set an "impossible" task to code (in C) an address book and calendar solution with a GUI (this is the mid-90s) in 6 hours. No internet connection and no reference books.
3 hours later I set off to find the interviewer in the pub.
Interview 2:
Set a series of questions around "write the most effective code to do X".
There were 10 questions and I answered them in 10 different programming languages (Ada, C, Prolog, C++, Eiffel, 68k assembler, LISP, SQL, COBOL, Fortran) and the chap interviewing me didn't have a clue if I was right or wrong.
Interview 3:
They had a major bug in a current release, my job was to find the bug and explain why it happened. I knew free work when I saw it. It was a big C programme and it took me 4 hours to find the bug (pointer referencing problem). I wandered into the office of the person setting the "test" and said...
"How much to tell you the answer"
I didn't go for any of these. What I went for, and what I have done since, is go for the company that set me an abstract test that asked me to design a system which had a number of constraints. They didn't want code, just to see the conceptual model that I would create. When I joined I asked why they did it this way and the answer was enlightening....
"Because we want to hire smarter people than we are. If you talk code then its just about optimising, but if you talk about the abstract then its about thinking. We want people who give us answers we think are wrong and then they explain why we are wrong."
The key point was to give people a limited time (15-30 minutes) to understand the problem and propose the solution. You want people who are agile and quick, not people who can sit on their arses for 6 hours doing a troll job.
If you want to hire people dumber than you, set complex long tests that "only you" know the answers to. If you want to hire smart thinking people set very short tests that challenge their abstract thinking.