Hi. I am sorry if this question is not so relevant to this forum/board, but i've got much help in here in the past and this forum is great so i decided to ask here.
Actually i am programming a board game in C (Gomoku), and I need to make a function that can tell if a certain square on the board (the board is represented by an array of size 225, e.g 15x15 board) is a border square / edge square. one can visualize the array as follows:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
15,16,17..... and so on. when the upper line is the North border and the 0,15 is the west border etc.
I thought of two ways to do it: i can make a simple function that takes an int (the square in question) and check one by one, with a conditional, to see if it matches to any of the border numbers.
Or i can do it like this: i can insert all the border indexes into a static array of 60 numbers which is already sorted, and do a binary search.Code:int checkBorder(int n){ if(n == 0 || n == 1 || .... return 1; } else{ return 0; }
what will be the fastest method?