Rewrite all python solutions using proper convention, and functional approach