Python based algorithm implementation