Ad
  • Custom User Avatar

    The problem is not with the section of code that you quoted, the problem is with your areOpposite function. You are summing the first letter of each direction to see if they are opposites, but this doesn't really work because two possible direction combinations sum to the same number. Manually check 'N' + 'N' and 'W' + 'E', and you should see what I mean. In this case, anytime your areOpposite function is called for NORTH and NORTH, it will return true, which is not what you want.