As a side note, these kinds of tasks are also pretty common in at my university in the practical computer science courses.
Often, you aren't supposed to write a big thing at once, but you are given some partially working code, with some incomplete set of test cases. You then have to finish the implementation, and you are also encouraged to add more test cases.
I found it especially interesting that the test cases were incomplete on purpose - you are supposed to understand and solve the given task, not just to blindly write some code that happens to pass a given set of tests.
Or given the same codebase have them add a feature and some form of testing.
There are many ways to simulate in a highly compressed manner the typical tasks of a programmer without resorting to algorithmic puzzles.