#MATLAB, 144 bytes
MATLAB, 144 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
u=2;v=0;x=1;y=1;n=1;for s=t
if s==9 x=x+u-v;y=y+v+u;a=v;v=u;u=-a;elseif s<11
n=n+1;x=1;y=n;else
o(y,x)=s;x=x+u/2;y=y+v/2;end
end
I started out with 209 bytes, but some more careful golfing got rid of most of that; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong. Edit: Tom Carpenter managed to prove me wrong; he managed to save 9 bytes which I optimized to save a whopping 29 bytes. Last byte saved by assuming there are no control characters (ASCII < 9) in the input - MATLAB strings aren't null-terminated.
#MATLAB, 144 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
u=2;v=0;x=1;y=1;n=1;for s=t
if s==9 x=x+u-v;y=y+v+u;a=v;v=u;u=-a;elseif s<11
n=n+1;x=1;y=n;else
o(y,x)=s;x=x+u/2;y=y+v/2;end
end
I started out with 209 bytes, but some more careful golfing got rid of most of that; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong. Edit: Tom Carpenter managed to prove me wrong; he managed to save 9 bytes which I optimized to save a whopping 29 bytes. Last byte saved by assuming there are no control characters (ASCII < 9) in the input - MATLAB strings aren't null-terminated.
MATLAB, 144 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
u=2;v=0;x=1;y=1;n=1;for s=t
if s==9 x=x+u-v;y=y+v+u;a=v;v=u;u=-a;elseif s<11
n=n+1;x=1;y=n;else
o(y,x)=s;x=x+u/2;y=y+v/2;end
end
I started out with 209 bytes, but some more careful golfing got rid of most of that; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong. Edit: Tom Carpenter managed to prove me wrong; he managed to save 9 bytes which I optimized to save a whopping 29 bytes. Last byte saved by assuming there are no control characters (ASCII < 9) in the input - MATLAB strings aren't null-terminated.
#MATLAB, 148144 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
u=1;v=0;x=0;y=1;n=1;foru=2;v=0;x=1;y=1;n=1;for s=t
if s==9
x=x+2*u x=x+u-2*v;y=y+2*v+2*u;a=v;v=u;u=v;y=y+v+u;a=v;v=u;u=-a;elseif s<11
n=n+1;x=0;y=n;elsen=n+1;x=1;y=n;else
x=x+u;y=y+v;oo(y,x)=s;end=s;x=x+u/2;y=y+v/2;end
end
I started out with 209 bytes, but some more careful golfing got rid of most of that; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong. Edit: Tom Carpenter managed to prove me wrong; he managed to save 9 bytes which I optimized to save a whopping 2529 bytes. Last byte saved by assuming there are no control characters (ASCII < 9) in the input - MATLAB strings aren't null-terminated.
#MATLAB, 148 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
u=1;v=0;x=0;y=1;n=1;for s=t
if s==9
x=x+2*u-2*v;y=y+2*v+2*u;a=v;v=u;u=-a;elseif s<11
n=n+1;x=0;y=n;else
x=x+u;y=y+v;o(y,x)=s;end
end
I started out with 209 bytes, but some more careful golfing got rid of most of that; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong. Edit: Tom Carpenter managed to prove me wrong; he managed to save 9 bytes which I optimized to save a whopping 25 bytes. Last byte saved by assuming there are no control characters (ASCII < 9) in the input - MATLAB strings aren't null-terminated.
#MATLAB, 144 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
u=2;v=0;x=1;y=1;n=1;for s=t
if s==9 x=x+u-v;y=y+v+u;a=v;v=u;u=-a;elseif s<11
n=n+1;x=1;y=n;else
o(y,x)=s;x=x+u/2;y=y+v/2;end
end
I started out with 209 bytes, but some more careful golfing got rid of most of that; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong. Edit: Tom Carpenter managed to prove me wrong; he managed to save 9 bytes which I optimized to save a whopping 29 bytes. Last byte saved by assuming there are no control characters (ASCII < 9) in the input - MATLAB strings aren't null-terminated.
#Matlab#MATLAB, 174148 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
d=0;x=0;y=1;n=1;foru=1;v=0;x=0;y=1;n=1;for s=t
u=(~d)-(d==2);v=(d==1)-(d>2);ifif s==9
x=x+2*u-2*v;y=y+2*v+2*u;d=mod(d+1,4);elseif2*v;y=y+2*v+2*u;a=v;v=u;u=-a;elseif s==10s<11
n=n+1;x=0;y=n;else
x=x+u;y=y+v;o(y,x)=s;end
end
I managed to shave off 35started out with 209 bytes (!) by, but some more careful golfing;golfing got rid of most of that; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong. Edit: Tom Carpenter managed to prove me wrong; he managed to save 9 bytes which I optimized to save a whopping 25 bytes. Last byte saved by assuming there are no control characters (ASCII < 9) in the input - MATLAB strings aren't null-terminated.
#Matlab, 174 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
d=0;x=0;y=1;n=1;for s=t
u=(~d)-(d==2);v=(d==1)-(d>2);if s==9
x=x+2*u-2*v;y=y+2*v+2*u;d=mod(d+1,4);elseif s==10
n=n+1;x=0;y=n;else
x=x+u;y=y+v;o(y,x)=s;end
end
I managed to shave off 35 bytes (!) by some more careful golfing; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong.
#MATLAB, 148 bytes
The weapon of choice for dealing with strings is of course a language designed for manipulating numbers [citation needed]. Kidding aside, the great thing about Matlab is that it doesn't care if you assign to an array 'out of bounds': it will simply make a larger matrix. Furthermore, the default matrix element, 0, is rendered as a space instead of a null character the ASCII spec prescribes.
Tabs are simply a jump in coordinates, so no spaces are outputted for a tab.
function o=q(t)
u=1;v=0;x=0;y=1;n=1;for s=t
if s==9
x=x+2*u-2*v;y=y+2*v+2*u;a=v;v=u;u=-a;elseif s<11
n=n+1;x=0;y=n;else
x=x+u;y=y+v;o(y,x)=s;end
end
I started out with 209 bytes, but some more careful golfing got rid of most of that; there's a lot of repetition in this code, so I did some trial-and-error which alternatives worked best. I don't think there's much space for more optimization with this code, but I'm always happy to be proven wrong. Edit: Tom Carpenter managed to prove me wrong; he managed to save 9 bytes which I optimized to save a whopping 25 bytes. Last byte saved by assuming there are no control characters (ASCII < 9) in the input - MATLAB strings aren't null-terminated.