Gild interview question

Programming puzzles. It may vary.