A coding exercise, knocked up to brush up on C.