# Print "N NE E SE S SW W NW"

This seems almost trivial, but since after some effort I was not able to beat the literal solution in J, I thought it might make a decent challenge (though, to be clear, this is not a J-specific challenge).

Title says it all. You simply need to write a program, or function (taking no arguments) that returns or prints:

N NE E SE S SW W NW


You may use newlines in place of spaces.

A no-argument function returning an array of strings such as

['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']


is also acceptable.

The letters may be upper or lower case, but may not be mixed.

• Perhaps allowing them to be output in any order would be slightly more interesting
– Jo King
Jun 10, 2019 at 0:14
• @JoKing Sure, I'll remove that. Honestly, I didn't expect anyone to submit answers that used the full literal value -- that's not in the spirit of the question. As I state, it came up because I wasn't able to beat the literal in J, despite the string having regularity and structure of a sort. The whole point is to exploit that regularity to beat a literal answer. Bad on me for not being more explicit. Allowing them any order defeats that as well, so I don't want to make that change. Jun 10, 2019 at 1:27
• @UnrelatedString The most promising idea I've had is to note that the directions correspond to i raised to the powers 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5. Unfortunately the J code required to then map those results into letters ended up being more expensive than a literal. Jun 10, 2019 at 18:04
• Ah, smart! I wonder if the mapping might work better for the Gaussian integers 1, 1+i, i, -1+i, -1, -1-i, -i, 1-i so you've got one real or imaginary part per cardinal direction instead of two. It's probably harder to generate those though, unless there's some way you could round those powers of i away from 0? I don't know how easy or hard that would be in J, but it's an idea. Jun 11, 2019 at 2:26
• It feels like entries should also show the naive "echo this string" version in their language for comparison, and judging be done on the % shortened? Jun 11, 2019 at 22:07

# Assembly (x86, Linux), 68 bytes

$od -x a 0000000 457f 464c 0001 0000 0000 0000 0000 0500 0000020 0002 0003 001b 0500 001b 0500 0004 0000 0000040 13b2 31b9 0000 cd05 2580 0020 0001 cd40 0000060 4e80 4e20 2045 2045 4553 5320 5320 2057 0000100 2057 574e 0000104$ ./a
N NE E SE S SW W NW$ Source: BITS 32 org 0x05000000 db 127,"ELF" dd 1,0 dd$$dw 2,3 dd 0x0500001B,0x0500001B dd 4 mov dl,19 mov ecx,m int 128 db 37 dw 32,1 inc eax int 0x80 m db 'N NE E SE S SW W NW'  Code mostly taken from Shortest ELF for "Hello world\n"? # A0A0, 69 bytes P78P32P83 P32P83P87 P78P69P32 P69P32P87 P32P83P32 P69P32P78 G-6G-6P87  Not much to this one, Px prints the character corresponding to ascii value x, so we just print the correct values. G-6 jumps back to the top. Splitting the code into three columns is optimal for saving bytes on new lines, while not using too many bytes on additional jumps. Two columns gives the same amount of bytes, but three columns is nicer to display on this site. # Malbolge, 151126118 115 bytes (&<@#!\}5Y9z1Uv4tQsr)M-n%I#"!&DBe/R-_<ts[Jp$5WUk1ShmPkd*uts%G#bElkW\>-Y+:utTR5P2HMk/-h++@d'&%;:^8~6}Y32V0T.uQ+N


Try it online!

• Well done! (Fill) Feb 1, 2022 at 18:57

# Pip-s, 20 bytes

Just barely shorter than printing the literal string.

"NESW"WV<>"NESESWNW"


Attempt This Online!

### Explanation

"NESW"WV<>"NESESWNW"
WV              Weave
"NESW"                the characters of this string
with
"NESESWNW"  this string
<>            taken in blocks of 2 characters each
Result: ["N";"NE";"E";"SE";"S";"SW";"W";"NW"]
Autoprint, space-separated (-s flag)


I added the unary version of <> because of this challenge, although I'm sure it will be useful elsewhere too.

# Jelly, 16 bytes

“æṖØq’ḃ⁴ḃ4ị“NESW


Try it online!

With footer to print separated by space

A niladic link which returns a list of strings. 2 bytes shorter (and arguably more interesting) than the compressed string in Jelly.

# C# (Visual C# Interactive Compiler), 24 bytes

_=>"N NE E SE S SW W NW"


Try it online!

• This also works in Javascript. Jun 10, 2019 at 4:19
• Polyglot with Foo. Jun 12, 2019 at 4:29
• what other characters are allowed besides '_' ? Jul 3, 2019 at 13:12

# R, 26 bytes

cat('N NE E SE S SW W NW')


Try it online!

As input to Commodore BASIC, you can get it even shorter: (23 bytes)

0 ?"N NE E SE S SW W NW


? is shorthand for PRINT.

• ? and PRINT use the same number of BASIC tokens so you are not saving any memory in your stored symbolic listing. Jul 2, 2019 at 12:09

# Java, 24 bytes

Quick, gotta do it before anyone else

v->"N NE E SE S SW W NW"

• According to the meta it indeed is allowed to take an unused null argument when a challenge states no input. I suggest using the Void class as input, since it has no useful static calls nor purposes. Try it online. EDIT: Ah, I see you had that initially, so you could roll-back and perhaps add the meta-post. ;) Jun 11, 2019 at 13:38
• @KevinCruijssen I rolled it back Jun 11, 2019 at 13:57

# ><>, 25 24 bytes

This is a pretty simple answer. Push the string in reverse, then print the stack. Exits with an error due to stack underflow.

"WN W WS S ES E EN N">o<


Try it online!

• You can remove the skip and it still works, doesn't it? Jun 11, 2019 at 15:35
• @squid Indeed. I originally was using | instead of the arrows. Jun 11, 2019 at 18:10
• If superfluous spaces are allowed, you can shave off one more byte "WN WWS SES EEN N">ooa<. Jun 18, 2019 at 9:33
• @PidgeyUsedGust codegolf.stackexchange.com/questions/186582/… Jun 18, 2019 at 14:27

# Assembly (MIPS, SPIM), 71 70 bytes

.data
t:.ascii"N NE E SE S SW W NW"
.text
main:li $2,4 la$4,t
syscall


Try it online!

I haven't done anything with MIPS in a while, so if there's a shorter way please tell me!

Edit: used an ascii and not an asciiz string

# k, 23 bytes

1_,/'$,/NS,/:\:EW  ## Keg, 19 bytes Simply hard-coding the answer. N NE E SE S SW W NW  # Stax, 16 bytes Ä\8←ΘåÑ¥▒Nx╚ø┼Çt  Run and debug it # SQL, 28 26 bytes On behalf of BradC: PRINT'N NE E SE S SW W NW'  SELECT 'N NE E SE S SW W NW' • You can save 2 bytes with PRINT'N NE E SE S SW W NW' Sep 19, 2019 at 13:50 • @BradC: Also thought about this, but I am not sure it matches the rules, because, yes, it prints desired result, but in principle returns nothing. But you may be right. Sep 19, 2019 at 13:53 • We pretty routinely use whichever of PRINT or SELECT is shorter/more useful for SQL-language challenges on CodeGolf, see the SQL language tips thread. Either way you can drop the space before the quote. Sep 19, 2019 at 14:43 # Jelly, 14 bytes 8ḶHị“eSwN”Ṣ€Œu  Try it online! Niladic link returning a list of strings.  H Halve 8Ḷ each number in 0 .. 7, ị“eSwN” and modular 1-index each into “eSwN”. Not only is ị modular, but it also handles fractional indices by flooring and ceiling them, returning a list of both elements. Ṣ€ Sort each, placing lowercase letters after uppercase. Œu Uppercase.  Come to think of it, this returns a ragged array of characters, rather than a real list of strings, so I guess you can slap a K on the end and call it a full program if that’s an issue. I guess the Ṣ actually does wrap non-list arguments. # Perl 5, 21 bytes <N {N,,S}E S {S,,N}W>  Standard glob function emulating *nix shell. See perldoc -f glob for more details. ### Alternative, 21 bytes <N NE E SE S SW W NW>  Didn't need to use qw since glob splits on whitespace and treats each pattern separately. • This doesn’t appear to be in the correct order May 20, 2021 at 1:49 • I thought your comment alluded to relaxing that requirement – Zaid May 20, 2021 at 1:49 • It’s a bit confusing, but read the last two sentences of the comment and it should be clear. May 20, 2021 at 1:52 • The first part of that was referring to a now deleted comment about disallowing snippets – Jo King May 20, 2021 at 2:48 • How is this 14 bytes? Feb 22, 2022 at 9:11 # Thunno 2, 13 bytes “£ḂA⁷<ọŒ⁼Ẓ2Ẏ®  Simple compressed string. Add the Ụ flag if you want it in uppercase. #### Screenshot # Haskell, 21 bytes I don't think it gets any shorter than this in Haskell. "N NE E SE S SW W NW"  Try it online! # Ruby, 22 bytes p'N NE E SE S SW W NW'  Try it online! One more Python example: for i in range(8):print''.join(c*((i+m)%8<3)for c,m in zip('NSEW',(1,5,7,3))),  I tried to use no cryptic operations, just normal math + boolean logic. Try it # Stax, 16 bytes Æ+góïr!½*ÄJ╓╨°╩Æ  Run and debug it # Assembly (x86, GCC), 151 bytes $ cat foo.s
.global _start
.text
_start:mov $1,%rax mov$1,%rdi
mov $m,%rsi mov$19,%rdx
syscall
mov $60,%rax xor %rdi,%rdi syscall m:.ascii "N NE E SE S SW W NW"$ gcc -c foo.s && ld foo.o && ./a.out
N NE E SE S SW W NW$ • Suggest mov$60,%al Jun 19, 2019 at 10:35
• lea can save you some \$. (e.g. lea 1,%eax) May 20, 2021 at 19:52

# DC, 79 bytes

78sn7Dss69se87swAsblblwlnlblwlblwlslblslblelslblelblelnlblnPPPPPPPPPPPPPPPPPPPP


It loads the characters NESW and newline into registers, then loads them onto the stack and prints them all

(N NE E SE S SW W NW)S


Pretty self explanatory

Try it online!

# Befunge-93, 45 bytes

"WN W":" "\"S":" "\" ES E":" "\"N":" "\>:#,_@


Try it online!

• Or just hardcode the string
– Jo King
Jul 12, 2019 at 9:41
• @JoKing I am aware that this is an option, but I didn't want to just hardcode it Jul 12, 2019 at 11:26

# Python 2, 26 bytes

print'N NE E SE S SW W NW'


Try it online!

Why make things complicate when we can do simple??

# Red, 25 bytes

prin"N NE E SE S SW W NW"


Try it online!

Transcript show:'N NE E SE S SW W NW'

'N NE E SE S SW W NW'print