There is no algorithm for love, but this solution may help.