Isaimini.6 -

Example implementation outline (pseudocode):