Skip to main content
3 of 4
accept & improve suggested edit adding decision problem tag
Karl
  • 871
  • 4
  • 14

Detect round trips on a hyperbolic grid

You're driving along a street in an infinite city whose blocks are pentagons arranged in the order-4 pentagonal tiling. At each step, you proceed to the next intersection and choose to go either left, right, or straight. A sequence of choices that returns you to your initial state (street and direction) is called a round trip.

Write a function (or program) that takes a string of L/R/Ss and returns (or outputs) one of two values, indicating whether the input represents a round trip.

Examples:

LLLLL -> yes LLLLSRRRRS -> yes SRRSRRSRRSRR -> yes (empty sequence) -> yes R -> no LLLLLL -> no (starts with a round trip but leaves initial state) SLLLLR -> no (returns to initial street but opposite direction) 
Karl
  • 871
  • 4
  • 14