In my code, I have a cell in a matrix with 8 neighbours (horizontal, vertical and diagonal). I need to implement a condition such as
CONDITION 2 = When three of any of the 8 neighbors (V1, V2, V3, ... V8) are equal to some value like 'X'. But i dont wanna use a code like below when i have to write all the possibilities. How could I write this better ?
Code:#define COND2 (V1==V2==V3=='X') || (V1==V2==V4=='X') || (V1==V2==V5=='X') || (V1==V2==V6=='X') || (V1==V2==V7=='X') || (V1==V2==V8=='X') ||