Alphabet Spiral

You are to write a program or function that outputs this exact text:

OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB


May also be lowercase and trailing spaces and newlines are allowed.

Standard loopholes are disallowed

This is , so smallest byte count wins.

• Can the lines have trailing spaces? Aug 13, 2016 at 18:23
• @Dennis Yes, I will edit the question to clarify that. Aug 13, 2016 at 18:26
• in case you wonder about the ascii codes of the spiral: puu.sh/qAitG/dd89c615cf.png Aug 13, 2016 at 22:03
• This output seems far too “complex” (in the Kolmogorov sense, i.e. devoid of pattern). Golf-y languages can hope to compress it, or in the case of MATL, hope to have a spiral built-in — but IMO it’s a bad sign if the best approach to a kolmogorov-complexity challenge is ever “just print the output as a string literal” (see Python).
– Lynn
Aug 13, 2016 at 22:15
• @Lynn Feel free to downvote if you think it's a bad question. That's what it's there for. I'll keep that in mind for next time though. Aug 13, 2016 at 22:28

MATL, 28 26 bytes

1Y2tIL)P0v7lYLP2:JTF-JQ&()


Try it online!

Explanation

1Y2     % Push string 'AB...Z'
tIL)    % Duplicate, remove last: gives 'AB...Y'
P       % Flip: gives 'YX...A'
0       % Push 0. Char 0 is treated as space
v       % Concatenate into a column vector of char
7lYL    % 7x7 numeric array: clockwise spiral of numbers from 1 to 49
P       % Flip vertically to make it anti-clockwise
2:      % Push [1 2]. Will be attached vertically after the last col
JqJh    % Index "[end-1, end]", to be used as row index
JQ      % Index "end+1", to be used as column index
&(      % Assign [1 2] to those positions. The rest of the new col will contain 0
)       % Index into the char vector. Indexing is modular and 1-based, so 0 as an
% index refers to the last value of the char vector, which is char 0, or
% equivalently space. So the 0 values in the numeric array give spaces.
% Implicitly display

• I have no idea how this works. Well done! Aug 13, 2016 at 17:49
• @DanTheMan I just added an explanation... I hope that helps! Aug 13, 2016 at 17:50
• I feel like the only language that could programmatically beat this is charcoal. Apr 11, 2017 at 14:46

Python 2, 69 bytes

print'''OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB'''


Just do it...

• how boring. im afraid this would beat the actual answer in python tho.. Aug 13, 2016 at 21:45

Bubblegum, 47 bytes

A hex dump, courtesy of xxd:

00000000: 520a adf6 2e08 7444 c41e c8ff 4096 ca2d  R.....tD....@..-
00000010: 8832 2297 8cd7 1bb1 fe10 43ce 39cc 8e5f  .2".......C.9.._
00000020: 31f7 3d63 432e d3f3 3873 ecf7 7641 a3    1.=cC...8s..vA.


(This is just the spiral, “compressed”.)

Try it online.

Fourier, 143 141 bytes

Not a particularly interesting answer except that it stores newlines (ASCII code 10) as the variable T... Uses isaacg's golfing program.

79a^a^a^a^a^a^a10a~T78a81avavavava86aTa77a82a69avava76a87aTa76a83a70a65a^a75a88aTa75a84a71a^a^a^a89a10a74a85a^a^a^a^a^a65aTa73avavavavavavava


Try it online

Try it online!

Python 3, 72 bytes

print('OPQRSTU\nNQPONMV\nMREDCLW\nLSFABKX\nKTGHIJY\nJUVWXYZA\nIHGFEDCB')


Not exactly interesting, but it still works!

• Use '''s instead of 's. Sep 28, 2016 at 12:22
• @EriktheGolfer It'd be a duplicate if he did that. Sep 28, 2016 at 13:35
• @mbomb007 I don't think so, because the other one is Python 2. Python 3 is different AFAIK, but, if it would be a dupe, I don't see why it isn't a dupe like this. Sep 28, 2016 at 13:37
• @EriktheGolfer When the only difference is a pair of parentheses and the version of the language, and the method used is identical, it's a duplicate. Just because versions are slightly different, doesn't mean you can provide the exact same answer in every version of a language without it being a duplicate. Sep 28, 2016 at 18:41
• @mbomb007 As I said before, why isn't this, as it is right now, a dupe then? The method is the same, the only differences are 1) Quoting type (does not change functionality) and 2) Parentheses, because the print statement is now a function, but that doesn't change anything, except that print is out of the builtins (and enhanced). So, why isn't this still a dupe then? Sep 29, 2016 at 10:44

PHP, 130 bytes

for($p=30,$s=1,$r=_;$i<51;$r[$p]=chr(90-abs(25-$i++)),$p+=$s*(9-$d))if(!$n||!$c=++$c%$n)($d=8-$d)?$n++:$s=-$s;echo wordwrap($r,8);


literally draws the spiral. Run with -r

breakdown

for($p=30,$s=1,$r=_; // initialize position to 3*9+3,$s(ign) to +1, $r(esult) to string // implicit$c(ount)=$d(irection)=$i(ndex)=le($n)gth=0$i<51;              // loop $i from 0 to 50$r[$p]=chr(90-abs(25-$i++)),// 2. set current position in string to correct character
$p+=$s*(9-$d)) // 3. move cursor if(!$n||!$c=++$c%$n) // 1. if 1st iteration ($n==0) or ++$c has rotated around$n
($d=8-$d)                   // negate $direction (0=horizontal, 8=vertical) ?$n++                   // if vertical: increase length
:$s=-$s                 // else invert sign
;
// output: wrap to lines of 8 characters
echo wordwrap($r,8); // having left spaces avoids need to provide 3rd and 4th parameter  Easy to extend: For more alphabet, append %50 after $i++, replace 51 with the wanted number, modify 8-$d, 9-$d, $p=30 and the wordwrap width to the new dimensions. JavaScript ES6, 62 bytes a=>OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB  Try it let f=a=>OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB; console.log(f()); Ruby, 63 bytes In this case, nothing I found beats the boring answer... puts"OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB"  My best solution that didn't print the literal string only, but still has to directly hardcode some of it, is 110 bytes: w=[*?B..?Q].reverse*'' puts [*?O..?U]*'',[?N,w[0,5],?V]*'',"MREDCLW LSFABKX KTGHIJY",[?J,*?U..?Z,?A]*'',w[8,8]  ///, 57 bytes OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB  Try it online! Just another boring answer. Move on! • Darn, I was 52561024 seconds late! Apr 11, 2017 at 14:57 Lua, 69 bytes print([[OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB]])  At least it works! 05AB1E, 46 bytes •ûk2šÄ>¸©W$V-ÏfQ*LnHO”Ïmsqšƒ1ËUðhd@ý(™š•36B1¡»


Try it online!

Won't win by any means, but it does work.

C#, 151145136 130 bytes

namespace a{class P{static void Main(){System.Console.Write("OPQRSTU\nNQPONMV\nMREDCLW\nLSFABKX\nKTGHIJY\nJUVWXYZA\nIHGFEDCB");}}}


Again, a boring one that does the trick.

Saved 6 bytes thanks to auhmaan.

• You can save some bytes by replacing using System; ... Console.Write("...") with System.Console.Write("...") Apr 11, 2017 at 15:00
• You don't need a namespace. You can also compile to a Func<string> to save even more bytes: ()=>"OPQRSTU\nNQPONMV\nMREDCLW\nLSFABKX\nKTGHIJY\nJUVWXYZA\nIHGFEDCB"; Jun 1, 2017 at 14:46
• You can save 5 bytes by using a string literal by prepending @ to the string before the quotes and then replacing the \n with literal new lines Jun 1, 2017 at 18:35
• You can save 2 more bytes by using namespace System and Console.Write instead of namespace a and System.Console.Write Jun 2, 2017 at 7:37

Windows batch, 84 bytes

@for %%p in (OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB) do @echo %%p


Simple enough for loop to loop through the strings.

Japt, 54 52 bytes

opqÏ
nqpmv
mdclw
lsfabkx
ktgjy
juvwxyza
ihgfcb


Try it online

Explanation

Simply a compressed string of the spiral in lowercase.

Modern Pascal 2.0, 122 bytes

 Write('OPQRSTU'+#13#10+'NQPONMV'+#13#10+'MREDCLW'+#13#10+'LSFABKX'+#13#10+'KTGHIJY'+#13#10+'JUVWXYZA'+#13#10+'IHGFEDCB');
`

Explanation Simply embed CRLF into the string, and display it.

// Author of Modern Pascal