python implementation of Cyrus-Beck algorithm