003 c algo from anon and tenative python translated version