Discover the answers to your questions at Westonci.ca, where experts share their knowledge and insights with you. Explore thousands of questions and answers from a knowledgeable community of experts ready to help you find solutions. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.

You need to get to the mall to buy some new shoes, but you're not sure how to get there. Your city is a n×m rectangular grid of blocks, where your home is located at the coordinates (x1,y1) and the mall's location is (xz,y2). Since you're not sure exactly how to get to the mall, you follow a movement strategy based on these rules: - Move diagonally on each move, starting in the direction (+1,+1). It means that standing at a cell with coordinates ( x, y ) , you'll move to the cell with coordinates (x+1,y+1) unless the new cell is outside the city grid, - If the current move would take you outside the city grid, come back and reverse the direction that was leading outside the grid (eg: if the x coordinate is outside the grid, reverse the x movement direction), - If the current move would escape the city grid outside of a corner, reverse both directions. Your task is to determine how many steps it will take to reach the mall at (x2,y2). Return −1 if it's not possible to reach the mall using this strategy.