Solution of Algorithm Problems in Python