# [Python 3], 111 bytes <!-- language-all: lang-python --> def f(s): u,f,r,l,b,d='WGROBY' for c in s: if'R'==c:u,f,d,b=b,u,f,d else:u,l,d,r=l,d,r,u return'WG'==u+f [Try it online!][TIO-l8etf782] There are a few ways I can think to shave off a few bytes, but I'll just leave it like this, since this approach isn't anywhere near competitive anyway. Happy to hear about other tweaks, though! - -5: Take a boolean array as input, so `if'R'==c:` can be just `if c:` - -1: Or just change `if'R'==c:` to `if'L'<c:` - -1: Change the lettering scheme from `WGROBY` to `ABCDEF` so `'WG'==u+f` can be `'AC'>u+f` [Python 3]: https://docs.python.org/3/ [TIO-l8etf782]: https://tio.run/##HUy7CgMhEOz9iu1Usl26A5s0aQIBm5DW0yWCeMeqxX292TsGhmFe@9F/W73PGRMBmWYXBQMJGQsGjE5/nv79@GoFtDGskCs0qUAm7bVz63KWIwYX8FISpdKS2EVsdhfjUMCpD65yJ6txo7lzrt2Q0f51Qls7/w "Python 3 – Try It Online"