6
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Can the lines have trailing spaces? \$\endgroup\$ – Dennis Aug 13 '16 at 18:23
  • \$\begingroup\$ @Dennis Yes, I will edit the question to clarify that. \$\endgroup\$ – DanTheMan Aug 13 '16 at 18:26
  • 1
    \$\begingroup\$ in case you wonder about the ascii codes of the spiral: puu.sh/qAitG/dd89c615cf.png \$\endgroup\$ – downrep_nation Aug 13 '16 at 22:03
  • 3
    \$\begingroup\$ 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). \$\endgroup\$ – Lynn Aug 13 '16 at 22:15
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ – DanTheMan Aug 13 '16 at 22:28

15 Answers 15

16
\$\begingroup\$

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
\$\endgroup\$
  • \$\begingroup\$ I have no idea how this works. Well done! \$\endgroup\$ – DanTheMan Aug 13 '16 at 17:49
  • \$\begingroup\$ @DanTheMan I just added an explanation... I hope that helps! \$\endgroup\$ – Luis Mendo Aug 13 '16 at 17:50
  • \$\begingroup\$ I feel like the only language that could programmatically beat this is charcoal. \$\endgroup\$ – Magic Octopus Urn Apr 11 '17 at 14:46
5
\$\begingroup\$

Python 2, 69 bytes

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

Just do it...

\$\endgroup\$
  • 5
    \$\begingroup\$ how boring. im afraid this would beat the actual answer in python tho.. \$\endgroup\$ – downrep_nation Aug 13 '16 at 21:45
2
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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!

\$\endgroup\$
1
\$\begingroup\$

Python 3, 72 bytes

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

Not exactly interesting, but it still works!

\$\endgroup\$
  • \$\begingroup\$ Use '''s instead of 's. \$\endgroup\$ – Erik the Outgolfer Sep 28 '16 at 12:22
  • \$\begingroup\$ @EriktheGolfer It'd be a duplicate if he did that. \$\endgroup\$ – mbomb007 Sep 28 '16 at 13:35
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ – Erik the Outgolfer Sep 28 '16 at 13:37
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ – mbomb007 Sep 28 '16 at 18:41
  • 1
    \$\begingroup\$ @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? \$\endgroup\$ – Erik the Outgolfer Sep 29 '16 at 10:44
1
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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]
\$\endgroup\$
0
\$\begingroup\$

///, 57 bytes

OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB

Try it online!

Just another boring answer. Move on!

\$\endgroup\$
  • \$\begingroup\$ Darn, I was 52561024 seconds late! \$\endgroup\$ – Comrade SparklePony Apr 11 '17 at 14:57
0
\$\begingroup\$

Lua, 69 bytes

print([[OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB]])

At least it works!

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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());

\$\endgroup\$
0
\$\begingroup\$

C#, 151 145 136 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.

\$\endgroup\$
  • \$\begingroup\$ You can save some bytes by replacing using System; ... Console.Write("...") with System.Console.Write("...") \$\endgroup\$ – auhmaan Apr 11 '17 at 15:00
  • \$\begingroup\$ 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"; \$\endgroup\$ – TheLethalCoder Jun 1 '17 at 14:46
  • \$\begingroup\$ 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 \$\endgroup\$ – PunPun1000 Jun 1 '17 at 18:35
  • \$\begingroup\$ You can save 2 more bytes by using namespace System and Console.Write instead of namespace a and System.Console.Write \$\endgroup\$ – Mr Scapegrace Jun 2 '17 at 7:37
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

Japt, 54 52 bytes

`opqÏ
nqpmv
mdclw
lsfabkx
ktgjy
juvwxyza
ihgfcb

Try it online


Explanation

Simply a compressed string of the spiral in lowercase.

\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.