"So what Google asks is not a brain teaser, not a math test, but a programming problem. It’s a simplified coding problem, designed (by trial and effort, mostly) to make sure a candidate has the most basic coding skills. Can you write a for loop and traverse an array? Do you know what sort of data structures are appropriate for what sort of situations? Do you recognize the inefficiency problem you might have when you traverse an array inside a loop that is itself traversing the array? Things like that. So, yeah, these problems might seem simplistic or offensive to you, but we ask them because a large proportion of our applicants simply can’t solve them."
Why we don’t hire programmers based on puzzles, API quizzes, math riddles, or other parlor tricks - (37signals)
I’m picking out a comment here, that is at odds with the article, but inline with my personal experience. A majority of web developers out there can’t actually program. They don’t think that this is relevant, because they can cut and paste some code, or Google for an answer. But because they can’t program, they are horrendously slow, and they can only ever achieve 80% of spec, not the awkward 20% that wasn’t in the cut and paste code. Programming tests weed these people out. You have to weed them out. A 1st class CompSci degree is usually a guarantee too, but not always.