Python solution of Cracking Coding Interview 5th edition