Implement the algorithm described in the [paper](https://www.sciencedirect.com/science/article/pii/S0377042705005534) of Alessandra Jannelli and Riccardo Fazio.