How to calculate the next available house?

0

At the moment I'm doing a project and I'm having a problem with an algorithm. Given the 4 directions (North, East, South, West), if the user chooses one of the 4, the next available home with 1 empty house should be allocated.

The house with coordinates (0,0) can not be occupied. If no one has created the account the first person to choose one of the directions is with the first house, for example Select North is with the N1, Select South is with S1. The second person to choose North would have the square with X to the left of N1.

How could you do to return the next available coordinate giving the direction as an argument?

    
asked by anonymous 23.03.2018 / 17:49

0 answers