first, ultra slow version, not passing tests (results are different in c++ and in python)