# 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 '19 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. – Jonah Jun 10 '19 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. – Jonah Jun 10 '19 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. – Unrelated String Jun 11 '19 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? – Dewi Morgan Jun 11 '19 at 22:07

# PowerShell, 21 bytes

'N NE E SE S SW W NW'


Try it online!

• Same in Swift Playground, with "N NE E SE S SW W NW", if you want. But too trivial to post. – Cœur Jun 10 '19 at 10:03
• this is code golf. see not trivial in the edit history. – mazzy Jun 10 '19 at 12:04

# 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. – Shaun Bebbers Jul 2 '19 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. ;) – Kevin Cruijssen Jun 11 '19 at 13:38
• @KevinCruijssen I rolled it back – Benjamin Urquhart Jun 11 '19 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? – Reinstate Monica Jun 11 '19 at 15:35
• @squid Indeed. I originally was using | instead of the arrows. – mbomb007 Jun 11 '19 at 18:10
• If superfluous spaces are allowed, you can shave off one more byte "WN WWS SES EEN N">ooa<. – PidgeyUsedGust Jun 18 '19 at 9:33
• @PidgeyUsedGust codegolf.stackexchange.com/questions/186582/… – mbomb007 Jun 18 '19 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' – BradC Sep 19 '19 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. – Jan Drozen Sep 19 '19 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. – BradC Sep 19 '19 at 14:43 # 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 – ceilingcat Jun 19 '19 at 10:35

# 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 '19 at 9:41
• @JoKing I am aware that this is an option, but I didn't want to just hardcode it – ItsJ0el Jul 12 '19 at 11:26