A simple recursive solver written in Python