#Dyalog APL , 63 bytes
Dyalog APL , 63 bytes
s@(n+11 9∘○しろまる ̈+0円j1*⊃ ̈,⍨\(8∘≠⍴ ̈⊢)0,'rdluRDLU'⍳ ̄1↓s)×ばつn←≢s←⍞
uses ⎕IO←0 and features from v16 (@)
n←≢s←⍞ raw input s and its length n
×ばつn create a 2n by 2n matrix of spaces
s@(...) amend the matrix with the characters of s at the specified (pairs of) indices
how the indices are computed:
̄1↓s drop the last char of s
'rdluRDLU'⍳' encode 'r' as 0, 'd' as 1, etc; other chars as 8
0, prepend a 0
(8∘≠⍴ ̈⊢) turn every 8 into an empty list, all others into a 1-element list
,⍨\ cumulative swapped concatenations (abcd -> a ba cba dcba)
⊃ ̈ first from each
0j1* imaginary constant i to the power of
+\ cumulative sums
11 9∘○しろまる ̈ real and imaginary part from each; get coords in the range -n...n
n+ centre them on the big matrix
#Dyalog APL , 63 bytes
s@(n+11 9∘○しろまる ̈+0円j1*⊃ ̈,⍨\(8∘≠⍴ ̈⊢)0,'rdluRDLU'⍳ ̄1↓s)×ばつn←≢s←⍞
uses ⎕IO←0 and features from v16 (@)
n←≢s←⍞ raw input s and its length n
×ばつn create a 2n by 2n matrix of spaces
s@(...) amend the matrix with the characters of s at the specified (pairs of) indices
how the indices are computed:
̄1↓s drop the last char of s
'rdluRDLU'⍳' encode 'r' as 0, 'd' as 1, etc; other chars as 8
0, prepend a 0
(8∘≠⍴ ̈⊢) turn every 8 into an empty list, all others into a 1-element list
,⍨\ cumulative swapped concatenations (abcd -> a ba cba dcba)
⊃ ̈ first from each
0j1* imaginary constant i to the power of
+\ cumulative sums
11 9∘○しろまる ̈ real and imaginary part from each; get coords in the range -n...n
n+ centre them on the big matrix
Dyalog APL , 63 bytes
s@(n+11 9∘○しろまる ̈+0円j1*⊃ ̈,⍨\(8∘≠⍴ ̈⊢)0,'rdluRDLU'⍳ ̄1↓s)×ばつn←≢s←⍞
uses ⎕IO←0 and features from v16 (@)
n←≢s←⍞ raw input s and its length n
×ばつn create a 2n by 2n matrix of spaces
s@(...) amend the matrix with the characters of s at the specified (pairs of) indices
how the indices are computed:
̄1↓s drop the last char of s
'rdluRDLU'⍳' encode 'r' as 0, 'd' as 1, etc; other chars as 8
0, prepend a 0
(8∘≠⍴ ̈⊢) turn every 8 into an empty list, all others into a 1-element list
,⍨\ cumulative swapped concatenations (abcd -> a ba cba dcba)
⊃ ̈ first from each
0j1* imaginary constant i to the power of
+\ cumulative sums
11 9∘○しろまる ̈ real and imaginary part from each; get coords in the range -n...n
n+ centre them on the big matrix