If I were given questions like these, I would politely refuse to answer them explaining they have nothing to do with the important things a typical software developer does.
Having a solid portfolio of past successful projects to demonstrate your abilities (including participation in a open source development) is way safer than being able to solve artificial problems.