This question is a simplification of the one about finding the shortest path in a grid with turnstile and waypoints. Since this simplification has dramatic consequences, I think it deserve its own question and answer.
Here's a reminder of how the turnstile tiles work.
- A turnstile tile has two bars on adjacent sides of the tile.
- You cannot step into a turnstile tile if it would mean crossing a bar.
- You can exit a turnstile tile in any direction.
- If you exit the tile in a direction where there was one of the bars, then the pair of bars rotate by a 1/4 turn such that there's no more bar in the direction you exited the tile from (see this video at 7:02).
Here's an example before and after exiting a turnstile tile:
How do we find the shortest path from A to B in a grid maze with turnstiles?