[Question]
  [
A friend of yours has given you directions to the best restaurant in town. It's a series of left and right turns. Unfortunately, they forgot to mention for how long you need to go straight ahead between those turns. Luckily you have a street map with all the restaurants on it. Maybe you can figure out which restaurant they meant?
## Input
The map is given as a rectangular grid of ASCII characters. `.` is a road, `#` is a building, `A` to `Z` are the various restaurants. You start in the top left corner, going east. Example:
```
.....A
.#.###
B....C
##.#.#
D....E
##F###
```
Your friend's instructions will be given as a (potentially empty) string or list of characters containing `L`s and `R`s.
## Output
You can walk any path that corresponds to the left and right turns in the input string, provided that you take at least one step forward before each of them, as well as at the end. In particular this means if the string starts with `R` you cannot go south immediately in the left-most column. It also means you can't turn around 180° on the spot.
You cannot walk through buildings or restaurants except the one you reach at the end. You may assume that the top left corner is a `.`.
You should output all the restaurants that can be reached with your friend's instructions, as a string or list.
You may assume that the instructions will lead to at least one restaurant. E.g. a single `L` would be invalid for the above map.
Some examples for the above map:
```
<empty> A
R       F
RR      B,D
RL      C,E
RLRL    E
RLLR    C
RLLL    B
RLRR    D
RLRRRR  A,C
RLLLRLL B
```
Note in particular that `R` doesn't reach `B`.
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
Standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply.
## Additional Test Cases
Here is a larger map, courtesy of [Conor O'Brien](https://codegolf.stackexchange.com/users/31957/c%E1%B4%8F%C9%B4%E1%B4%8F%CA%80-ob%CA%80%C9%AA%E1%B4%87%C9%B4) (which I modified a bit):
```
.......Y..........................######
.####.....#.##....##..######....#.###.##
B.........#.##.#..##....##...##.#.#P...#
.#.#####..#.##..#.##....##.#....#.####.#
.#.#...C..#.##...G##..#.##.#....#.#....#
.#.#.#.#..#.####.###.#..##.#....#.#.NO.#
.#.#A#.#..#.##...F###...##.#.##.#......#
.#.###....#.##....##....##.#....###....#
.#.....##...##....##...D##........###R.#
.#.##..##...##E...##..######....####...#
.....X....#.#.....................##S.T#
###########.###########M############...#
#................................###.#.#
#.#########.########.######.#.######.#.#
#......V#.....######.IJ...........##.#.#
#########.###......ZH############L##.#.#
#########.##########.###############.#.#
####K##...##########.#....#..........#.#
####....########U......##...#######Q.#.#
#####################################W.#
```
And here are a few selected lists of directions and their expected results:
```
<empty>                                 Y
RR                                      B
RLL                                     Y
RLRR                                    B,C,X
RLLLRRR                                 G
RLRLRLRL                                I,Z
RLLRRRLRRLRR                            C,D,F,G,Y
RLRRLLRLLLRL                            B,C,Y
RLLRRLRRRLLLL                           F,M,N,O,Y
RLRRLLLRRRRLLLL                         F,M,Y
RLRRLRRRRRRRRRR                         E,F,Y
RLRRRLLLRLLRRLL                         M,N,O
RLLRRLRRLRLRLRRLLR                      E,U
RLRLLRLRRLRRRRRLRL                      F,G,I,Z
RLLRRLLRLLRRRLRRLLRR                    W
RLLLRRRLRRLLLLLRLLLLLL                  D,G,X
RLRLLRLRRLRLRRRLRLLLRR                  B,C,E,J,X
RLRLRLLLLRLRRRRRRLRLRRLR                Y
RLRLRRRLRLLLLRLRRLLLLRLLRRL             E,M,X
RLRLLLRRRLLLRLLRLLRLRRLRLRR             B,E,F,K
RLRRRLLLLLLLLLLLLLLLRRRRLLL             A,B
```
Bonus question: is there an input that results in *only* `I` *or only* `U`? If so, what's the shortest such path?
  
[Answer]
# Perl, ~~150~~ ~~149~~ ~~146~~ ~~145~~ ~~141~~ ~~140~~ ~~138~~ ~~136~~ ~~135~~ ~~133~~ ~~130~~ ~~126~~ ~~125~~ 124
Added +7 for -F -Xn0i
An initial attempt.
Run with the map on STDIN and the directions after the -i option, e.g.
```
perl -F -Xn0iRL incomplete.pl
.....A
.#.###
B....C
##.#.#
D....E
##F###
```
Close STDIN with `^D` or `^Z` or whatever works on your operating system.
`incomplete.pl`:
```
%P=0;$^I=~s``{%;=!/
/;%P=map{$_|=$F[$^H=$_+=(1,@+,-1,"-@+")[$d&3]]=~/(\w)|#|^$/*~!\$;{$1}}(%P)x@F}$d-=B&$'^u`eg;print%
```
Replace the ^H by the literal control character to get the given score
Bonus question:
* There is no input that results in only `I`
* The shortest input that results in only `U` is `RLLRRLLRLRLRRLRRLRLRLRRLLR`
* The longest input needed to result in a unique set is `RLLRRRLRLRLLLRRLRLLLLLRRRLLRRRLLLLLLLRRLRRRR` which gives `B O R`
[Answer]
# Python 2, ~~180~~ ~~177~~ ~~168~~ ~~163~~ ~~161~~ 158 bytes
```
def a(v,o,c=0,A=0,d='.',O={0}):
 while'.'==d:w=v.find('\n');c+=[1,~w,-1,w+1][A%4];d=v[c];o>v<a(v+' '*w,o[1:],c,ord(o[0])-~A,d);d>v>o<O.add(d)
 return`O`[9::5]
```
Parameter `v` is the map as a string; `o` is the `LR` string.
Mitch Schwartz saved ~~2~~ ~~3~~ ~~10~~ lots of bytes. Thanks!
I saved two bytes by setting `O={0}` and returning ``O`[9::5]`, which might not be very portable: it assumes that `hash(0) == 0`, I think, because that causes the order of elements in `repr(O)` to be
```
set([0, 'A', 'B', 'C'])
```
and creatively slicing that string gets me the answer.
[Answer]
# C++ 364
**Thanks to @ceilingcat for finding a much better (and shorter) version**
```
#import<bits/stdc++.h>
#define M m[y][x]
using namespace std;vector<string>m;char n[99],j;int r(int x,int y,char*d,int z){for(;z%2?y+=z-2:(x-=z-1),y>=0&y<m.size()&x>=0&&m[y][x]&&!*d|M==46&&(!*d?n[M]+=M>64&M<91,M==46:!r(x,y,d+1,z+(*d-82?*d==76:3)&3)););}main(int c,char**v){for(string l;getline(cin,l);)m.push_back(l);for(r(0,0,v[1],0);j<99;j++)n[j]&&cout<<j<<" ";}
```
[Try it online!](https://tio.run/##LZBdb4IwFIbv@RVMsqaFwkCNG7Zo9nk1brwlZMGCWiaFABpg87ezVncuTvvkPSd5WlZV9p6xcTR4UZV1S7e8bR6aNmWW5RxWmpFmOy4yPdSLqI@jLtZODRd7XSRF1lQJy3Q5S84Za8uaNm0ts1VB2CGpdRH5foxzwkWr11D1DqveYxWb6RUG9LMra0iG@@m6t4LBni5hZ8vTQ7hfBS7oaeE0fMggAp1i8O8BwJ2Z/oZBMF8AAOV9LaIwtoJwtZiDkPoevmbLuxp2uMep5eHBgmZqP03XZhoEj4vlDIEZQgSRS5FwcTVkNzfzfNO6PUg/kn3WHuU3QMYFPsqVwqlOzeFrm7BvKFnN1tDFLj5HXoxdRHLq@yS3LCSiXLqy8tRSmlM60SfkMo6OqmfNMRzDMLQXRa@aYSjW3hS9S/qQ2bj53Mj6Aw "C++ (gcc) – Try It Online")
[Answer]
# Haskell, 257 bytes
```
import Data.List
t=transpose
r=reverse
l=length
f(m,x,y)=[(m,n,y)|n<-[x+1..l(m!!0)-1],notElem '#'[m!!y!!z|z<-[x..n]]]
i!c=[last$(t.r$m,l m-y-1,x):[(r.t$m,y,l(m!!0)-x-1)|c/='L']|(m,x,y)<-i>>=f]
m#i=intersect['A'..'Z'][a!!y!!x|(a,x,y)<-foldl(!)[(m,0,0)]i>>=f]
```
[Try it Online!](https://tio.run/##NY5Rb4MgEMff/RRaTIAMWX1dSpNu7Z588nGEB@LsSgZokCza@N0dWEtyd39@ufvf3eTw22q9LMr0nfPpWXpJKzX4xDPvpB36bmgTx1z717qgNNOt/fG35IoMGcmEGQ/CBjHbQ8HHl5JSjUyW7XFRCmI7f9GtSSGAPMApy@7zPfZRaoUQicoaxrUcfI48dbkhOjXFVJRkxG8cOeoDmsjTcCxKPDevDFZQzNv@Q6GOR3YViQGKKevjlY3n8AQphV9QcLmuHWckt/5rp781ynA8fE/2WDwMFiOVTVnau@CSIyN7hABO@Y7Gd9qRHQUUABDEeyQfQQAQWRDnSC4r@Yw9Ig6Gbx1jTdWatlI9ULXBeiv1E4cIFss/)
Calling `m#i` for a map `m` with a list of instructions `i` outputs the possible restaurants.
[Answer]
# Python3, 333 bytes:
```
m,n={1:{0:3,1:4},2:{0:4,1:3},3:{0:2,1:1},4:{0:1,1:2}},{1:(0,1),2:(0,-1),3:(1,0),4:(-1,0)}
def f(b,p,x,y,d):
 try:
   if b[x][y]=='.':
    x+=n[d][0];y+=n[d][1]
    if 64<ord(r:=b[x][y])<91 and not p:yield r
    if x>=0and y>=0:yield from f(b,p,x,y,d);yield from f(b,p[1:],x,y,m[d][p[0]=='L'])
 except:1
q=lambda b,p:set(f(b,p,0,0,1))
```
[Try it online!](https://tio.run/##lVRrb5swFP3uX2HFHzCbY0ESTRstk7r1sQfrNvYeQ1MyQENKgIInBVX89szGBpwspdqNYo59DsfX1zZFzX7n2fxxUe52G5K5t7ZzazlzYjuLhswEXnA8b8hc4BnHdkMWAtscz5qG8DewRWyTq/lzysHcwTaxTC7DUwEaEMUJTPCKFGRLahKZDoCsrHkLYZrAVbANgzp0XYMa7RjcPnSzIAoDKzypFbTDluHyR4vTvIxw6bjqRfP0iQ2XWQSznMHCqdN4HcGyk2@fupYga/5UXFLmm718Tg7HA9sJW24j5i54Ijw7zwhNAOPtr7hgjg1u3PVys4qWkOudKmZYOlpEVMPcVe5kMgFUxBmgiCKEwDPRew4QEn1wLnoXvHfJOSEWZWL5z1W@5OvjVSpj9qfMYLBOK4ZTM8lLmMI0g0m6ZnGJr/MsJrCiVbFOGTZ@ZIZphgAUZZoxfIN7p8okBqeOE/7dzAjljVCjpDdm6o3a@qOkP27s697G1Hgws0ygbRGl3@idgdoA7VMOUAlEK8luVPzlNg9CRDW5HEDvBFLHonWhQ6s0nSNSQnF0eslVL@@EtHeUve7dPoFeeP1WCc96IWcukZaeUg85Hq5ac0TD1Poiu/Zc1UxK/c6xF178W0eVidyZr9r6juzMB/oRATQE1fAbpBPCEdF7Aqm7qfnQA0B10Dl@RtpJoS9f7VlKoW4jme8v9AS9Y8Ijqxqm5vFaVVEj2nLpJxDohRXxieo71cb7/anH4gsXinvzn98ZT/5Gvw2@uMn33fT2Mkun3V8)
]