4 added 546 characters in body
source | link

PowerShell, 170 167 166

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d--}'M'{iex(-split'$y++ $x++ $y-- $x--')[$d%4]}}
"$x,$y,"+'NESW'[$d%4]

Not well-golfedCan't seem to golf this down further, which is a bit embarrassing. But all the obvious hacks don't really work here.

I can't iex the input because a) N, S, E and W would have to be functions for that to work (or I'd need to prefix that with $ and b) 1,2,N would have to parse the N in expression mode, not being able to run a command.

The switch seems to be the shortest way of doing the movement. Hash table with script blocks or strings isn't shorter either and for every other way apart from the switch I'd have the overhead of the explicit loop.

I can't get rid of the IndexOf because a pipeline with ? is longer, still.

I also can't get rid of the explicit types in the initial declaration because I have mixed types there, so fara simple |%{+$_} doesn't help and every other option is longer.

Sometimes I hate input handling in PowerShell.

PowerShell, 170 167 166

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d--}'M'{iex(-split'$y++ $x++ $y-- $x--')[$d%4]}}
"$x,$y,"+'NESW'[$d%4]

Not well-golfed so far.

PowerShell, 170 167 166

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d--}'M'{iex(-split'$y++ $x++ $y-- $x--')[$d%4]}}
"$x,$y,"+'NESW'[$d%4]

Can't seem to golf this down further, which is a bit embarrassing. But all the obvious hacks don't really work here.

I can't iex the input because a) N, S, E and W would have to be functions for that to work (or I'd need to prefix that with $ and b) 1,2,N would have to parse the N in expression mode, not being able to run a command.

The switch seems to be the shortest way of doing the movement. Hash table with script blocks or strings isn't shorter either and for every other way apart from the switch I'd have the overhead of the explicit loop.

I can't get rid of the IndexOf because a pipeline with ? is longer, still.

I also can't get rid of the explicit types in the initial declaration because I have mixed types there, so a simple |%{+$_} doesn't help and every other option is longer.

Sometimes I hate input handling in PowerShell.

3 added 10 characters in body
source | link

PowerShell, 170 167167 166

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d--}'M'{iex(-split'$y++ $x++ $y-- $x--')[$d%4]|iex[$d%4]}}
"$x,$y,"+'NESW'[$d%4]

Not well-golfed so far.

PowerShell, 170 167

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d--}'M'{(-split'$y++ $x++ $y-- $x--')[$d%4]|iex}}
"$x,$y,"+'NESW'[$d%4]

Not well-golfed so far.

PowerShell, 170 167 166

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d--}'M'{iex(-split'$y++ $x++ $y-- $x--')[$d%4]}}
"$x,$y,"+'NESW'[$d%4]

Not well-golfed so far.

2 deleted 3 characters in body
source | link

PowerShell, 170170 167

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d+=3$d--}'M'{('$y++','$x++','$y-split'$y++ $x++ $y--','$x $x--')[$d%4]|iex}}
"$x,$y,$('NESW'[$d%4])""+'NESW'[$d%4]

Not well-golfed so far.

PowerShell, 170

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d+=3}'M'{('$y++','$x++','$y--','$x--')[$d%4]|iex}}
"$x,$y,$('NESW'[$d%4])"

Not well-golfed so far.

PowerShell, 170 167

[int]$x,[int]$y,$e,$m="$input"-split'\W'
$d='NESW'.indexof($e)
switch([char[]]$m){'R'{$d++}'L'{$d--}'M'{(-split'$y++ $x++ $y-- $x--')[$d%4]|iex}}
"$x,$y,"+'NESW'[$d%4]

Not well-golfed so far.

1
source | link