Implementation of the shingling algorithm