Well, I have largely written a program, but I just realised it doesn't differentiate between water and land provinces (I assume you meant less than three neighbours of the same land/sea type). By the way, do you really mean less than three, or "three or less"?