generalised the code which finds the winning index for vertical columns