need some help guys with this algorithm

i need the algorithm that implements the 4-way and 8-way symmetry …