Python Algorithm Solutions