You do not need to write your function several times with the switch:
switch(a[i]){ case a[i-13]: case a[i+13]: case a[i-1]: case a[i+1]:
Interestingly, these are about the same number of characters (depending on how you format it). The switch statement is generally less efficient than the explicit if , but in this case I find it more clear and less error prone.
source share