source codes of the answers to the question in Crack Interview