Thursday, January 22, 2009

A common interview question — or at least it was five years ago — is to ask an alleged programmer and potential hire to write code to "shuffle a deck of cards".

The GNU C library, simply because it can, has the strfry(3) function.

I would explain further, but anyone not capable of synthesizing these two things without further explanation should probably not be trying to get a job as a programmer.

(Note to interviewers: your response should probably be along the lines of "Cool. Now implement strfry, so you can build this with straight bog-standard C/C++." Bonus points, on the other hand, if they define it on the spot, using appropriate #ifdefs.)

This function has no relationship whatsoever to the strfry(3D) function, which differs from strfry(3) in several respects; the two cannot be easily confused, since: a) they have distinct and incompatible type signatures, b) they are for different C libraries (glibc versus System V), and c) the latter is, thankfully, entirely fictional.

(Contrariwise, this function is related to the memfrob(3) function, on the grounds that, while they may have distinct purposes, they exist for exactly the same reason.)

No comments: