Here you are! The solution offered by Claude Lapalme :
There also is a nice post on Scoring notes by Florian Kretlow:
Hope you find it useful