Prototypical implementation of gap calculation.