Draw a path made by direction changers












3












$begingroup$


This challenge takes place on a grid.



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+


This one's 10 x 10, but it can be any rectangular shape.



There are four directions on this grid. Up, down, left and right.



The task is to draw a path starting with an upper case direction initial. In this example, will go directly upward from the U.



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+


The path will go upwards and be comprised of full-stop characters (.), until it hits a wall, when it will terminate with an asterisk (*).



+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+


In addition to path starts, there's also direction changers, represented by a lower case direction initial.



+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+


Also, an upper case X us an obstacle which will terminate the path.



+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+




Rules




  • The input is a string consisting of a frame, (consisting of |, - and + characters) containing characters denoting path starts, direction changers, and obstacles.

  • Your code should add full stop characters to follow the path described by starts and direction changers, and an asterisk when/if the path meets a wall or obstacle.

  • There can be multiple path starts.

  • The code will still terminate without error if the path describes a loop.

  • If a path meets a path start, it will act as a direction changer.

  • It's code golf, low-byte code and no standard loopholes, please.

  • I always prefer links to an on-line interpreter.




Test Cases



1: Simple



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+


2: Right turn



+----------+
| |
| |
| |
| r |
| |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+


3: Crossroads



+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| . r..d |
| . . . |
| u....l |
| . |
| . |
| U |
+----------+


4: 4 Crossing paths



+----------+
| D |
| |
| |
|R |
| |
| L|
| |
| |
| U |
+----------+


+----------+
| * D |
| . . |
| . . |
|R........*|
| . . |
|*........L|
| . . |
| . . |
| U * |
+----------+


5: First Loop



+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+

+----------+
| |
| |
| |
| r..d |
| . . |
| u..l |
| . |
| . |
| U |
+----------+


6: Starter as changer



+----------+
| |
| |
| |
| L |
| |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
|*..L |
| . |
| . |
| . |
| . |
| U |
+----------+


7: Straight Loop



+----------+
| |
| |
| |
| |
| r l |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| |
| r..l |
| . |
| . |
| . |
| U |
+----------+


8: Tight Knot



+----------+
| |
| |
| |
| d l |
| r u |
| r u |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| d..l |
| .r.u |
| r.u |
| . |
| . |
| U |
+----------+


9: An Obstacle



+----------+
| |
| |
| |
| |
| r X |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+


10: S Shape



+----------+
|r d |
| |
| XXXXXXXX|
| d l |
|ul |
|XXXXXXX |
| |
|R u |
| |
+----------+


+----------+
|r.....d |
|. * |
|. XXXXXXXX|
|.d......l |
|ul . |
|XXXXXXX . |
| . |
|R.......u |
| |
+----------+


11: 4-Way Knot



+----------+
| D |
| |
| r |
|R d |
| |
| u L|
| l |
| |
| U |
+----------+


+----------+
| * D |
| . . |
| r.....*|
|R....d. |
| .... |
| .u....L|
|*.....l |
| . . |
| U * |
+----------+


12: Busy Junctions



+----------+
|rrrrr rrrd|
| rlrl |
|ul rrd |
|ruX X |
|udl ll |
|ull |
|rlr |
|rdr d |
|Uruull |
+----------+


+----------+
|rrrrr.rrrd|
|.rlrl .|
|ul rrd .|
|ruX.X. .|
|udl.ll .|
|ull. .|
|rlr. .|
|rdr..d .|
|Uruull *|
+----------+


13: Starts Into Edge



+----------+     
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+

+----------+
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+


14: Crossing Dead Paths



+----------+    
| |
| |
| |
| R |
| |
| |
| |
| |
| U|
+----------+


+----------+
| *|
| .|
| .|
| R..*|
| .|
| .|
| .|
| .|
| U|
+----------+









share|improve this question











$endgroup$












  • $begingroup$
    @TFeld Added, thanks!
    $endgroup$
    – AJFaraday
    55 mins ago
















3












$begingroup$


This challenge takes place on a grid.



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+


This one's 10 x 10, but it can be any rectangular shape.



There are four directions on this grid. Up, down, left and right.



The task is to draw a path starting with an upper case direction initial. In this example, will go directly upward from the U.



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+


The path will go upwards and be comprised of full-stop characters (.), until it hits a wall, when it will terminate with an asterisk (*).



+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+


In addition to path starts, there's also direction changers, represented by a lower case direction initial.



+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+


Also, an upper case X us an obstacle which will terminate the path.



+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+




Rules




  • The input is a string consisting of a frame, (consisting of |, - and + characters) containing characters denoting path starts, direction changers, and obstacles.

  • Your code should add full stop characters to follow the path described by starts and direction changers, and an asterisk when/if the path meets a wall or obstacle.

  • There can be multiple path starts.

  • The code will still terminate without error if the path describes a loop.

  • If a path meets a path start, it will act as a direction changer.

  • It's code golf, low-byte code and no standard loopholes, please.

  • I always prefer links to an on-line interpreter.




Test Cases



1: Simple



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+


2: Right turn



+----------+
| |
| |
| |
| r |
| |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+


3: Crossroads



+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| . r..d |
| . . . |
| u....l |
| . |
| . |
| U |
+----------+


4: 4 Crossing paths



+----------+
| D |
| |
| |
|R |
| |
| L|
| |
| |
| U |
+----------+


+----------+
| * D |
| . . |
| . . |
|R........*|
| . . |
|*........L|
| . . |
| . . |
| U * |
+----------+


5: First Loop



+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+

+----------+
| |
| |
| |
| r..d |
| . . |
| u..l |
| . |
| . |
| U |
+----------+


6: Starter as changer



+----------+
| |
| |
| |
| L |
| |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
|*..L |
| . |
| . |
| . |
| . |
| U |
+----------+


7: Straight Loop



+----------+
| |
| |
| |
| |
| r l |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| |
| r..l |
| . |
| . |
| . |
| U |
+----------+


8: Tight Knot



+----------+
| |
| |
| |
| d l |
| r u |
| r u |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| d..l |
| .r.u |
| r.u |
| . |
| . |
| U |
+----------+


9: An Obstacle



+----------+
| |
| |
| |
| |
| r X |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+


10: S Shape



+----------+
|r d |
| |
| XXXXXXXX|
| d l |
|ul |
|XXXXXXX |
| |
|R u |
| |
+----------+


+----------+
|r.....d |
|. * |
|. XXXXXXXX|
|.d......l |
|ul . |
|XXXXXXX . |
| . |
|R.......u |
| |
+----------+


11: 4-Way Knot



+----------+
| D |
| |
| r |
|R d |
| |
| u L|
| l |
| |
| U |
+----------+


+----------+
| * D |
| . . |
| r.....*|
|R....d. |
| .... |
| .u....L|
|*.....l |
| . . |
| U * |
+----------+


12: Busy Junctions



+----------+
|rrrrr rrrd|
| rlrl |
|ul rrd |
|ruX X |
|udl ll |
|ull |
|rlr |
|rdr d |
|Uruull |
+----------+


+----------+
|rrrrr.rrrd|
|.rlrl .|
|ul rrd .|
|ruX.X. .|
|udl.ll .|
|ull. .|
|rlr. .|
|rdr..d .|
|Uruull *|
+----------+


13: Starts Into Edge



+----------+     
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+

+----------+
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+


14: Crossing Dead Paths



+----------+    
| |
| |
| |
| R |
| |
| |
| |
| |
| U|
+----------+


+----------+
| *|
| .|
| .|
| R..*|
| .|
| .|
| .|
| .|
| U|
+----------+









share|improve this question











$endgroup$












  • $begingroup$
    @TFeld Added, thanks!
    $endgroup$
    – AJFaraday
    55 mins ago














3












3








3





$begingroup$


This challenge takes place on a grid.



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+


This one's 10 x 10, but it can be any rectangular shape.



There are four directions on this grid. Up, down, left and right.



The task is to draw a path starting with an upper case direction initial. In this example, will go directly upward from the U.



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+


The path will go upwards and be comprised of full-stop characters (.), until it hits a wall, when it will terminate with an asterisk (*).



+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+


In addition to path starts, there's also direction changers, represented by a lower case direction initial.



+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+


Also, an upper case X us an obstacle which will terminate the path.



+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+




Rules




  • The input is a string consisting of a frame, (consisting of |, - and + characters) containing characters denoting path starts, direction changers, and obstacles.

  • Your code should add full stop characters to follow the path described by starts and direction changers, and an asterisk when/if the path meets a wall or obstacle.

  • There can be multiple path starts.

  • The code will still terminate without error if the path describes a loop.

  • If a path meets a path start, it will act as a direction changer.

  • It's code golf, low-byte code and no standard loopholes, please.

  • I always prefer links to an on-line interpreter.




Test Cases



1: Simple



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+


2: Right turn



+----------+
| |
| |
| |
| r |
| |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+


3: Crossroads



+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| . r..d |
| . . . |
| u....l |
| . |
| . |
| U |
+----------+


4: 4 Crossing paths



+----------+
| D |
| |
| |
|R |
| |
| L|
| |
| |
| U |
+----------+


+----------+
| * D |
| . . |
| . . |
|R........*|
| . . |
|*........L|
| . . |
| . . |
| U * |
+----------+


5: First Loop



+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+

+----------+
| |
| |
| |
| r..d |
| . . |
| u..l |
| . |
| . |
| U |
+----------+


6: Starter as changer



+----------+
| |
| |
| |
| L |
| |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
|*..L |
| . |
| . |
| . |
| . |
| U |
+----------+


7: Straight Loop



+----------+
| |
| |
| |
| |
| r l |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| |
| r..l |
| . |
| . |
| . |
| U |
+----------+


8: Tight Knot



+----------+
| |
| |
| |
| d l |
| r u |
| r u |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| d..l |
| .r.u |
| r.u |
| . |
| . |
| U |
+----------+


9: An Obstacle



+----------+
| |
| |
| |
| |
| r X |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+


10: S Shape



+----------+
|r d |
| |
| XXXXXXXX|
| d l |
|ul |
|XXXXXXX |
| |
|R u |
| |
+----------+


+----------+
|r.....d |
|. * |
|. XXXXXXXX|
|.d......l |
|ul . |
|XXXXXXX . |
| . |
|R.......u |
| |
+----------+


11: 4-Way Knot



+----------+
| D |
| |
| r |
|R d |
| |
| u L|
| l |
| |
| U |
+----------+


+----------+
| * D |
| . . |
| r.....*|
|R....d. |
| .... |
| .u....L|
|*.....l |
| . . |
| U * |
+----------+


12: Busy Junctions



+----------+
|rrrrr rrrd|
| rlrl |
|ul rrd |
|ruX X |
|udl ll |
|ull |
|rlr |
|rdr d |
|Uruull |
+----------+


+----------+
|rrrrr.rrrd|
|.rlrl .|
|ul rrd .|
|ruX.X. .|
|udl.ll .|
|ull. .|
|rlr. .|
|rdr..d .|
|Uruull *|
+----------+


13: Starts Into Edge



+----------+     
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+

+----------+
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+


14: Crossing Dead Paths



+----------+    
| |
| |
| |
| R |
| |
| |
| |
| |
| U|
+----------+


+----------+
| *|
| .|
| .|
| R..*|
| .|
| .|
| .|
| .|
| U|
+----------+









share|improve this question











$endgroup$




This challenge takes place on a grid.



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+


This one's 10 x 10, but it can be any rectangular shape.



There are four directions on this grid. Up, down, left and right.



The task is to draw a path starting with an upper case direction initial. In this example, will go directly upward from the U.



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+


The path will go upwards and be comprised of full-stop characters (.), until it hits a wall, when it will terminate with an asterisk (*).



+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+


In addition to path starts, there's also direction changers, represented by a lower case direction initial.



+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+


Also, an upper case X us an obstacle which will terminate the path.



+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+




Rules




  • The input is a string consisting of a frame, (consisting of |, - and + characters) containing characters denoting path starts, direction changers, and obstacles.

  • Your code should add full stop characters to follow the path described by starts and direction changers, and an asterisk when/if the path meets a wall or obstacle.

  • There can be multiple path starts.

  • The code will still terminate without error if the path describes a loop.

  • If a path meets a path start, it will act as a direction changer.

  • It's code golf, low-byte code and no standard loopholes, please.

  • I always prefer links to an on-line interpreter.




Test Cases



1: Simple



+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+


2: Right turn



+----------+
| |
| |
| |
| r |
| |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+


3: Crossroads



+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| . r..d |
| . . . |
| u....l |
| . |
| . |
| U |
+----------+


4: 4 Crossing paths



+----------+
| D |
| |
| |
|R |
| |
| L|
| |
| |
| U |
+----------+


+----------+
| * D |
| . . |
| . . |
|R........*|
| . . |
|*........L|
| . . |
| . . |
| U * |
+----------+


5: First Loop



+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+

+----------+
| |
| |
| |
| r..d |
| . . |
| u..l |
| . |
| . |
| U |
+----------+


6: Starter as changer



+----------+
| |
| |
| |
| L |
| |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
|*..L |
| . |
| . |
| . |
| . |
| U |
+----------+


7: Straight Loop



+----------+
| |
| |
| |
| |
| r l |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| |
| r..l |
| . |
| . |
| . |
| U |
+----------+


8: Tight Knot



+----------+
| |
| |
| |
| d l |
| r u |
| r u |
| |
| |
| U |
+----------+


+----------+
| * |
| . |
| . |
| d..l |
| .r.u |
| r.u |
| . |
| . |
| U |
+----------+


9: An Obstacle



+----------+
| |
| |
| |
| |
| r X |
| |
| |
| |
| U |
+----------+


+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+


10: S Shape



+----------+
|r d |
| |
| XXXXXXXX|
| d l |
|ul |
|XXXXXXX |
| |
|R u |
| |
+----------+


+----------+
|r.....d |
|. * |
|. XXXXXXXX|
|.d......l |
|ul . |
|XXXXXXX . |
| . |
|R.......u |
| |
+----------+


11: 4-Way Knot



+----------+
| D |
| |
| r |
|R d |
| |
| u L|
| l |
| |
| U |
+----------+


+----------+
| * D |
| . . |
| r.....*|
|R....d. |
| .... |
| .u....L|
|*.....l |
| . . |
| U * |
+----------+


12: Busy Junctions



+----------+
|rrrrr rrrd|
| rlrl |
|ul rrd |
|ruX X |
|udl ll |
|ull |
|rlr |
|rdr d |
|Uruull |
+----------+


+----------+
|rrrrr.rrrd|
|.rlrl .|
|ul rrd .|
|ruX.X. .|
|udl.ll .|
|ull. .|
|rlr. .|
|rdr..d .|
|Uruull *|
+----------+


13: Starts Into Edge



+----------+     
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+

+----------+
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+


14: Crossing Dead Paths



+----------+    
| |
| |
| |
| R |
| |
| |
| |
| |
| U|
+----------+


+----------+
| *|
| .|
| .|
| R..*|
| .|
| .|
| .|
| .|
| U|
+----------+






code-golf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 55 mins ago







AJFaraday

















asked 1 hour ago









AJFaradayAJFaraday

3,24642855




3,24642855












  • $begingroup$
    @TFeld Added, thanks!
    $endgroup$
    – AJFaraday
    55 mins ago


















  • $begingroup$
    @TFeld Added, thanks!
    $endgroup$
    – AJFaraday
    55 mins ago
















$begingroup$
@TFeld Added, thanks!
$endgroup$
– AJFaraday
55 mins ago




$begingroup$
@TFeld Added, thanks!
$endgroup$
– AJFaraday
55 mins ago










1 Answer
1






active

oldest

votes


















5












$begingroup$


Python 2, 283 279 293 288 bytes





e=enumerate
def f(M):
s=[(x,y,ord(c)%15%4)for y,l in e(M)for x,c in e(l)if'A'<c<'X'];v=set(s)
for x,y,d in s:
X,Y=[x,x+d-2,y-d+1,y][d%2::2];c=M[Y][X];N=(X,Y,('dlur'.find(c)+1or-~d)-1)
if'!'>c:M[Y][X]='.'
if(c in'-|X')*('/'>M[y][x]):M[y][x]='*'
if(c in'udlr. *')>({N}<v):v|={N};s+=N,


Try it online!



Takes a list of lists.



Outputs by modifying the input array.






share|improve this answer











$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "200"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f179083%2fdraw-a-path-made-by-direction-changers%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5












    $begingroup$


    Python 2, 283 279 293 288 bytes





    e=enumerate
    def f(M):
    s=[(x,y,ord(c)%15%4)for y,l in e(M)for x,c in e(l)if'A'<c<'X'];v=set(s)
    for x,y,d in s:
    X,Y=[x,x+d-2,y-d+1,y][d%2::2];c=M[Y][X];N=(X,Y,('dlur'.find(c)+1or-~d)-1)
    if'!'>c:M[Y][X]='.'
    if(c in'-|X')*('/'>M[y][x]):M[y][x]='*'
    if(c in'udlr. *')>({N}<v):v|={N};s+=N,


    Try it online!



    Takes a list of lists.



    Outputs by modifying the input array.






    share|improve this answer











    $endgroup$


















      5












      $begingroup$


      Python 2, 283 279 293 288 bytes





      e=enumerate
      def f(M):
      s=[(x,y,ord(c)%15%4)for y,l in e(M)for x,c in e(l)if'A'<c<'X'];v=set(s)
      for x,y,d in s:
      X,Y=[x,x+d-2,y-d+1,y][d%2::2];c=M[Y][X];N=(X,Y,('dlur'.find(c)+1or-~d)-1)
      if'!'>c:M[Y][X]='.'
      if(c in'-|X')*('/'>M[y][x]):M[y][x]='*'
      if(c in'udlr. *')>({N}<v):v|={N};s+=N,


      Try it online!



      Takes a list of lists.



      Outputs by modifying the input array.






      share|improve this answer











      $endgroup$
















        5












        5








        5





        $begingroup$


        Python 2, 283 279 293 288 bytes





        e=enumerate
        def f(M):
        s=[(x,y,ord(c)%15%4)for y,l in e(M)for x,c in e(l)if'A'<c<'X'];v=set(s)
        for x,y,d in s:
        X,Y=[x,x+d-2,y-d+1,y][d%2::2];c=M[Y][X];N=(X,Y,('dlur'.find(c)+1or-~d)-1)
        if'!'>c:M[Y][X]='.'
        if(c in'-|X')*('/'>M[y][x]):M[y][x]='*'
        if(c in'udlr. *')>({N}<v):v|={N};s+=N,


        Try it online!



        Takes a list of lists.



        Outputs by modifying the input array.






        share|improve this answer











        $endgroup$




        Python 2, 283 279 293 288 bytes





        e=enumerate
        def f(M):
        s=[(x,y,ord(c)%15%4)for y,l in e(M)for x,c in e(l)if'A'<c<'X'];v=set(s)
        for x,y,d in s:
        X,Y=[x,x+d-2,y-d+1,y][d%2::2];c=M[Y][X];N=(X,Y,('dlur'.find(c)+1or-~d)-1)
        if'!'>c:M[Y][X]='.'
        if(c in'-|X')*('/'>M[y][x]):M[y][x]='*'
        if(c in'udlr. *')>({N}<v):v|={N};s+=N,


        Try it online!



        Takes a list of lists.



        Outputs by modifying the input array.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 29 secs ago

























        answered 1 hour ago









        TFeldTFeld

        14.7k21241




        14.7k21241






























            draft saved

            draft discarded




















































            If this is an answer to a challenge…




            • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


            • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
              Explanations of your answer make it more interesting to read and are very much encouraged.


            • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



            More generally…




            • …Please make sure to answer the question and provide sufficient detail.


            • …Avoid asking for help, clarification or responding to other answers (use comments instead).





            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f179083%2fdraw-a-path-made-by-direction-changers%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Ponta tanko

            Tantalo (mitologio)

            Erzsébet Schaár