Skip to main content
7 of 17
added 672 characters in body
user41805
  • 13.2k
  • 6
  • 42
  • 88

Röda, 405 393 392 391 bytes

F f{f=f/"
"seq 0,#f-1|f[_]=f[_1]/""l=[sort(f,cmp={|a,b|[#a<#b]})]seq 0,#f-1|f[_].=[" "]*(#l[#l-1]-#f[_1])c=""x=0
y=0
X=1
Y=0
while[c!=";"]do
l=f[y]c=l[x]
[c]
{X=1;Y=0}if[c=">"]
{X=-1;Y=0}if[c="<"]
{X=0;Y=1}if[c="v"]
{X=0;Y=-1}if[c="^"]
{a=X;X=-Y;Y=-a}if[c="/"]
{a=X;X=Y;Y=a}if[c=`\`]
X=-X if[c="|"]
Y=-Y if[c="_"]
{X=-X;Y=-Y}if[c="#"]
x+=X
x=x%#l
y+=Y
y=y%#f
x+=#l if[x<0]
y+=#f if[y<0]done}

Try it online!

Check outputs!

Some 20-30 bytes go to parsing the input (I have asked the OP for a more relaxed input format and am now waiting for their response) and 80-ish bytes go to padding spaces when necessary.

###Ungolfed

F f{
  f=f/"
"
  seq 0,#f-1|f[_]=f[_1]/""
  l=[sort(f,cmp={|a,b|[#a<#b]})]
  seq 0,#f-1|f[_].=[" "]*(#l[#l-1]-#f[_1])
  c=""
  x=0
  y=0
  X=1
  Y=0
  while[c!=";"]do
    l=f[y]
    c=l[x]
    [c]
    {X=1;Y=0}if[c=">"]
    {X=-1;Y=0}if[c="<"]
    {X=0;Y=1}if[c="v"]
    {X=0;Y=-1}if[c="^"]
    {a=X;X=-Y;Y=-a}if[c="/"]
    {a=X;X=Y;Y=a}if[c=`\`]
    X=-X if[c="|"]
    Y=-Y if[c="_"]
    {X=-X;Y=-Y}if[c="#"]
    x+=X
    x=x%#l
    y+=Y
    y=y%#f
    x+=#l if[x<0]
    y+=#f if[y<0]
  done
}

###Edits

  • 10 bytes saved thanks to @fergusq by using % instead of checking whether x or y is over the boundaries, which paved the way for 2 more!
  • Used `\</code> instead of "\"`
  • Moved c="" to the second line and then removed the newline following it
user41805
  • 13.2k
  • 6
  • 42
  • 88