Cetak “N NE E SE S SW W NW”


47

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.


9
Perhaps allowing them to be output in any order would be slightly more interesting
Jo King

3
@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

3
@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

1
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

3
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

Jawaban:


18

Canvas, 12 bytes

>X½+T)AuS{⁹‟

Try it here!

The string, simply compressed.


2
Can you explain how this works in a little more detail?
Dillanm

2
@Dillanm there isn't much more to say - Canvas has a built-in compressor (should be accessible with ctrl+o → string compress) that, here, simply stores the characters needed ("NESW ") and then in base-5 stores the individual characters.
dzaima

56

bash (24 bytes)

using brace expansion

echo N {N,,S}E S {S,,N}W

is the same length as hard coding

echo N NE E SE S SW W NW

however it becomes more interesting when outputing more points of the compass

echo N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW

brace expansion

echo N {{N,,E}N,,{E,,S}S}E S {{S,,W}S,,{W,,N}N}W

otherwise if order could be changed, (17 bytes), the trick is that without quotes the empy string parameter disappears

echo {N,,S}{W,,E}

1
That is interesting, I didn't know that you could have empty position is the brace expression!
flawr

1
@flawr Useful when chrooting: mount -t proc{,,}
gronostaj

7
Or cp file{,.bak}
Oliphaunt

43

Mornington Crescent, 4395 3823 bytes

Take Northern Line to Bank
Take District Line to Parsons Green
Take District Line to Paddington
Take Bakerloo Line to North Wembley
Take Bakerloo Line to Charing Cross
Take Bakerloo Line to Charing Cross
Take Bakerloo Line to Charing Cross
Take Bakerloo Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Barbican
Take Circle Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Embankment
Take Bakerloo Line to Charing Cross
Take Bakerloo Line to Charing Cross
Take Bakerloo Line to Charing Cross
Take Bakerloo Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Bayswater
Take Circle Line to Hammersmith
Take Circle Line to Baker Street
Take Circle Line to Bank
Take Circle Line to Embankment
Take Northern Line to Stockwell
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Farringdon
Take Circle Line to Hammersmith
Take Circle Line to Blackfriars
Take Circle Line to Bank
Take Circle Line to Moorgate
Take Northern Line to Waterloo
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Westminster
Take Circle Line to Hammersmith
Take Circle Line to Tower Hill
Take Circle Line to Bank
Take Circle Line to Edgware Road
Take Circle Line to Liverpool Street
Take Central Line to Mile End
Take District Line to Victoria
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take District Line to Mile End
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Barbican
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bayswater
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Baker Street
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Farringdon
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Embankment
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Blackfriars
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Moorgate
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Westminster
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Tower Hill
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Aldgate
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Edgware Road
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent

Try it online!

Since it's a bit much to expect you to read all that, let me give a quick overview of my approach. The main idea is to store 3 copies of the characters N,E,S,W at various stations on the Circle line, via Bank - Hammersmith. These characters are constructed from the start of a station name at Charing Cross. Then, construct   from the middle of a well-chosen station name using Mile End and Charing Cross, and store it at Bank so that it can be collected at Hammersmith in the concatenation. Finally, concatenate the characters one by one at Paddington, copying them again via Bank - Hammersmith if they are need to be reused later.


I think the current solution is fairly close to optimal with this strategy, at least in terms of number of stations visited: just 2 times I used a station only for transit:

  1. to get to Seven Sisters (via Victoria station)
  2. and to get back to Mornington Crescent (via Bank).

All other station visits were, if I didn't forget one, either storing/retrieving something useful or (part of) using the stations ability.

As for the line lengths, I've tried to pick the shortest names on Circle Line, but there may be a minor improvement there. It's possible that storing something on District can shave off a few bytes.


Two ideas to golf this some more: 1. take 'NE', 'SW', 'NW', 'SE' from a single station (Using e.g. Neasden, Swiss Cottage, Acton Town and Mansion House) 2. Try to exploit the fact that Paddington makes it easier to concatenate ` W ` rather than W . This does require some more overhead to 'refresh' Paddington, so it may not gain anything.
Discrete lizard

4
Does this use Dollis Hill loop rules? If so, I think it can be improved by use of an Argyle Street parabola, and maybe even a slightly modified version of the Webb-Ellis protocol.
Richard Ward


24

brainfuck, 142 139 131 119 bytes

++++++++++[>+++>+++++++>++++++++>+++++++++<<<<-]>>>--.<<++.>>.<-.<.>.<.>>+++++.<.<.>>.<<.>>.>---.<<<.>>>.<<<.>>-----.>.

Try it online!

Simply loops 10 times to fill the cells with 30, 70, 80 and 90 then steps backward and forwards and adjusts the cell values to print out the required characters. Not much different from the standard "Hello world!".


7
Lol I've never understood how anyone can "golf" these obscure languages. Its hard enough to understand what the code does in the first place (this is said coming from C++ / Java background)
mackycheese21

10
@mackycheese21 what? C++ didn't teach you to love pointer manipulation?
candied_orange

12
brainfuck might be esoteric, but I sure wouldn't call it obscure
Unrelated String

3
@candied_orange C++ taught me to hate pointer manipulation and run away whenever someone mentioned std:: :)
mackycheese21

1
@UnrelatedString obscure, no. Obtuse, yes.
Rich

14

Brain-Flak, 204 bytes

((((((((((((((((()()()){}()){}){}())){}{}))<([([][]){}()]{})(([][]){}[])>)<([][]
()())>)[[]]()())<([]()()())>)<((([]())[][]){}[][()])>)<([][()()])>[[]()])<([][((
)()){}])>)((()()())){}{})<((()()()()()){})>)

Try it online!


4
Points deducted for wrapping.
Rich

12

MarioLANG, 249 221 bytes

+
+
+
+
+
+
+
+
+  ((+++++++++)))<
+>==============="
)++++++++)+++((-[!)--.)++.(.---------.).(.).)++.((.).).(.).++++.(.).(.(+++++++++.))
=================#================================================================.

Try it online!



10

Excel Formula, 59 57 bytes

The following should be entered as an array formula (Ctrl+Shift+Enter):

=SUBSTITUTE(ADDRESS(1,{14,369,5,499,19,517,23,387},4),1,)

After entering the formula as an array formula, highlight it in the formula bar and evaluate it using F9 to return the result, for example:

Before:
Before formula evaluation

After:
Before formula evaluation

How it works

The ADDRESS function returns a string representing a reference based on two parameters, row and col. The third parameter controls what type of reference is returned, an absolute or relative reference. For example, =ADDRESS(1,2,4) returns "B1".

We can supply an array to ADDRESS and use it as an array formula to return multiple results, for example =ADDRESS(1,{1,2,3},4) returns "A1","B1","C1".

Therefore, in my answer, the array supplied to ADDRESS are just the column numbers relating to the required compass points, e.g. Column 14 is column N, Column 369 is column NE.

However, we are not finished here since all the returned references have the row included, for example, N1, NE1. Therefore, we simply use SUBSTITUTE to remove the 1 from all references.


1
Would =IF(1,"N NE E SE S SW W NW") be valid?
Reinstate Monica

3
@squid Yes it would indeed! However, I was going for an alternative which didn't require the string to be quoted verbatim.
i_saw_drones

How does this work?
anatolyg

@anatolyg I've added an explanation section, hope it's understandable.
i_saw_drones


7

Charcoal, 14 bytes

”{⊟“�_Zn↖⦄RüΦ≦

Try it online! Link is to verbose version of code... which is just the string to be printed, as the auto-deverbosifier takes care of the string compression.

Printing the string uncompressed takes 19 bytes, since Charcoal prints printable ASCII literally. The best algorithmic answer I could come up with unfortunately takes 20 bytes:

E⁸ΦSNWE›³﹪⁻﹪⁺⁵×⁶μχι⁸

Try it online! Outputs using array format (would cost two bytes to join the elements on spaces). Works by noticing that the letters of the string SNWE are used only when the current outer index equals or is 1 away (modulo 8) in either direction from the corresponding element of the list of indices 4,0,6,2.


7

brainfuck, 117 bytes

+++++[>++++++>+>+++>>++++>+++++<<<<<<-]>++[>++>++>+>++>++[<]>-]>>-.>.<.<.>>.<<.>>.>-.<<<.>>.>.<.>.>--.<<.>>.<<.<.>>>.

Try it online!

This code will first create the characters "EN SW" into the memory and then move back and forth to print them. The space is in the middle, because it is printed most often. N and S and W and E never appear together so they are on opposite sides of the memory. For optimization some of the final decrements happen during the output phase.


1
OK, that's a cool answer. Guess you beat me on this one. +1 for -1 :-)
ElPedro

1
BTW, forgot to say, welcome to the Code Golf site. Looking forward to competing with you in the future ☺
ElPedro

1
Welcome! Consider adding an explanation or a link to an online interpreter for the program. See other answers for examples. Short code-only answers tend to get automatically flagged as low-quality.
mbomb007

1
Thanks, I can add a explanation of my code. I will also try to understand how the online links work.
Helena

1
@Helena For the link you can check out the "Try it Online" link on my answer. If you paste your code in and run it you can then click on the link icon and get a perfectly formatted code golf answer that you can simply copy and paste here. Works like magic and supports many languages. Well worth a try.
ElPedro


5

Jelly,  16  15 bytes

“¤œỵpq⁵’ṃ“NESW 

A full program printing the text

Try it online!


16...

“¥Þ¡¦¢¬£æ‘ṃ“¡ɱ⁻»

A niladic Link which yields a list of lists of (lowercase) characters.

Try it online!


Alternative 15 as a niladic Link which yields a list of (lowercase) characters (with spaces): “¡XÇŀqỵÑ’ṃ“¡⁴ṁ».


5

Commodore BASIC (TheC64Mini, C64, C128, VIC-20 etc.) 28 Tokenized BASIC bytes used

 0 PRINT"N NE E SE S SW W NW

In Commodore BASIC, you do not require the closing quotation mark on PRINT or LET statements as the interpreter will auto-close it, this saves one BASIC token.

Alternatively, one may simply use direct mode as follows:

Commodore BASIC 23 PETSCII characters (+ RETURN to execute)

?"N NE E SE S SW W NW

I'm not sure how to count the number of bytes used in this instance as according to the interpreter ? and PRINT use the same number of bytes, and there is no program stored in memory.


1
PRINT can be replaced with ? as well, saving four bytes.
James

1
No, that's not true; PRINT and ? use the same amount of BASIC tokens. I'm not counting PETSCII characters as it's not very representative of how much of the available memory is being used by the interpreter.
Shaun Bebbers

1
After all of these years I'm still learning new stuff about the Commodore. Thanks Shaun! c64-wiki.com/wiki/BASIC_token
James

Here's one I made earlier (for the C64) -> pastebin.com/NMYzTC7k
Shaun Bebbers

4

Japt, 16 bytes

Returns an array of lowercase strings. The compressed string was 18 bytes but using a as the delimiter instead and then splitting on that worked out shorter.

`nÂà!Z°°nw`qa 

Try it - footer formats the output.


4

Deadfish~, 138 bytes

{{i}i}c{{d}}cs{i}c{d}ic{{d}}iisicsic{{d}}iisicisddddddc{d}ddddc{{d}}iisicisddddddc{{iiii}}sicisddddddciiiic{{d}d}icisddc{{d}d}ics{i}c{i}dc

Try it online!

So, outputting in lower-case with newlines is better than default (upper-case with spaces).

This code was generated by my optimizer, written in C++ (thanks to squid for another optimization idea!):

#include <iostream>
#include <string>
#include <queue>
#include <vector>


int eval(const std::string& actions, int result)
{
    int mult = 1;

    for (int i = 0; i < (int)actions.length(); ++i)
    {
        switch (actions[i])
        {
        case 's':
            result *= result;
            if (result == 256)
                result = 0;
            break;

        case '{':
            mult *= 10;
            break;

        case '}':
            mult /= 10;
            break;

        case 'd':
            if (result > 256 && result - mult <= 256)
                result = (result - mult) % 256;
            else
                result -= mult;
            break;

        case 'i':
            if (result < 256 && result + mult >= 256)
                result = (result + mult) % 256;
            else
                result += mult;
            break;
        }
    }

    return result;
}

struct worse
{
    bool operator()(const std::string& a1, const std::string& a2)
    {
        return a1.length() > a2.length();
    }
};

std::string BestStr(int accumulator, int target)
{
    std::priority_queue<std::string, std::vector<std::string>, worse> actions;
    actions.push(std::string(""));
    while (true)
    {
        std::string a = actions.top();
        int new_acc = eval(a, accumulator);
        if (new_acc == target)
            return a + "c";

        actions.pop();

        int last_braces = 0;
        int i = a.length() - 1;
        while (i >= 0 && a[i] == '}' && last_braces < 2)
        {
            ++last_braces;
            --i;
        }
        bool is_last_i = (i >= 0 && a[i] == 'i');
        bool is_last_d = (i >= 0 && a[i] == 'd');
        bool may_add_braces = (i < 0 || a[i] == 's');
        bool may_add_c = (new_acc > 1 && new_acc < 30);

        if (may_add_c)
        {
            actions.push(a + "s");
        }
        if (may_add_braces)
        {
            actions.push(a + "{{}}");
            actions.push(a + "{}");
        }
        for (int braces_back = 0; braces_back <= last_braces; ++braces_back)
        {
            for (int c = 'd'; c <= 'i'; c += 'i' - 'd')
            {
                if ((!is_last_i || c == 'i') &&
                    (!is_last_d || c == 'd') ||
                    braces_back == 0)
                {
                    std::string new_actions = a;
                    new_actions.insert(new_actions.length() - braces_back, 1, (char)c);
                    actions.push(new_actions);
                }
            }
        }
    }
}

std::string DeadfishConvert(std::string s)
{
    std::string result;
    int accumulator = 0;

    for (int c: s)
    {
        result += BestStr(accumulator, c);
        accumulator = c;
    }
    return result;
}

int main()
{
    std::string s1 = DeadfishConvert("N NE E SE S SW W NW");
    std::cout << s1 << '\n';
    std::cout << s1.length() << '\n' << '\n';
    std::string s2 = DeadfishConvert("n ne e se s sw w nw");
    std::cout << s2 << '\n';
    std::cout << s2.length() << '\n' << '\n';
    std::string s3 = DeadfishConvert("N\nNE\nE\nSE\nS\nSW\nW\nNW");
    std::cout << s3 << '\n';
    std::cout << s3.length() << '\n' << '\n';
    std::string s4 = DeadfishConvert("n\nne\ne\nse\ns\nsw\nw\nnw");
    std::cout << s4 << '\n';
    std::cout << s4.length() << '\n' << '\n';
}


4

Batch File, 19 bytes

The question never stated that you had to output N NE E SE S SW W NW and nothing else, nor that it couldn't exit due to error after doing so this code only throws an error but does not exit due to it.

N NE E SE S SW W NW

Output

>N NE E SE S SW W NW
'N' is not recognized as an internal or external command,
operable program or batch file.

Batch File, 25 bytes

Only N NE E SE S SW W NW output with no errors or crashes.

@echo N NE E SE S SW W NW

You could save a byte replacing cd with just quotes, like 'N NE E SE S SW W NW' - you'll get something like: N NE E SE S SW W NW - command not found
Dewi Morgan

4

Python2, 59 bytes

''.join(' SEWN'[0xe0619042210504>>i*3&7]for i in range(19))

The magic number is the joined three-bit indexes into the character string, reverse order so we can start iterating at the LSB.


I spent a while trying to shrink the magic number, but repeating the character string via multiply to allow for extra indexes doesn't work out due to needing to encode for space - best I got for overlapping indexes in the lookup added more characters to the string than digits removed from the magic number (including a couple of unfortunate don't-cares in the middle):

''.join('WN S ES W xxE '[0x423659711>>i*2&15]for i in range(19))

Why make ir simple when you can make it complicated? :-)
G B

4

K (ngn/k), 23 22 bytes

-1 byte thanks to ngn!

"WNES"@5\7108085518230

Try it online!

J, 34 30 bytes

echo(#:3510)<;.1'NNEESESSWWNW'

Try it online!


Galen, for J echoing the literal would be shorter. I would love to see that beat... I haven’t managed to do it
Jonah

1
Yes, echoing would be be 4+19 bytes. I don't have any better ideas to.
Galen Ivanov

1
for k: if we swap " "<->"W" (0<->4 in base 5), the space will be at the end and we can remove it because out-of-bounds string indexing gives a space anyway: "WNES"@5\7108085518230
ngn

@ngn Thank you!
Galen Ivanov

1
@GalenIvanov good for top-performance databases too :) arthur designed k as the underlying language for kdb+
ngn


3

Brachylog, 19 bytes

"NNEESESSWWNW"ḍ₄ḍᵐc

Try it online!

Outputs as a list. ḍ₄ḍᵐc saves two bytes over writing out seven spaces and making the entire predicate a string literal, so at least it ties PHP...

"NNEESESSWWNW"         The string "NNEESESSWWNW"
              ḍ₄       split into quarters
                 ᵐ     with each quarter
                ḍ      split in half
                  c    and concatenated
                       is the output.

I tried to be clever with 3⟦{;"NESW"↺₍h₂a₀ᶠ}ᵐc, but it couldn't get SE or NW right, and is a byte longer anyhow.


3

Whitespace, 151 bytes

[S S S T    T   N
_Push_3_W][S S T    T   T   S N
_Push_-6_N][S S T   T   T   S T S S N
_Push_-52_space][S S S T    T   N
_Push_3_W][S T  S S T   N
_Copy_0-based_1st_(space)][S S S T  T   N
_Push_3_W][S S T    T   N
_Push_-1_S][S T S S T   S N
_Copy_0-based_2nd_(space)][S S T    T   N
_Push_-1_S][S T S S T   N
_Copy_0-based_1st_(space)][S S T    T   T   T   T   N
_Push_-15_E][S S T  T   N
_Push_-1_S][S T S S T   S N
_Copy_0-based_2nd_(space)][S T  S S T   S N
_Copy_0-based_2nd_(E)][S T  S S T   N
_Copy_0-based_1st_(space)][S T  S S T   N
_Copy_0-based_1st_(E)][S S T    T   T   S N
_Push_-6_N][S T S S T   S N
_Copy_0-based_2nd_(space)][S S T    T   T   S N
_Push_-6_N][N
S S N
_Create_Label_LOOP][S S S T S T S T S S N
_Push_84][T S S S _Add][T   N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs, and new-lines only).

Explanation:

  1. Push the unicode values minus constant 84 for the characters "WN W WS S ES E EN N" to the stack (note that the string is pushed in reversed). In addition, I use a few copies of previously pushed values to save bytes where possible.
  2. Then start an infinite loop, which does the following:
    1. Add the constant 84 to the current unicode value
    2. Print it as character to STDOUT

The constant 84 is generated by this Java program which I wrote for another challenge I answered in Whitespace.


3

MathGolf, 20 17 bytes

ÿnesw▒∙╫m+mÉîÄ╪^─

-3 bytes thanks to @maxb.

Try it online.

Explanation:

ÿnesw      # Push 4-char string "nesw"
           #  STACK: "nesw"
          # Split to a list of characters
           #  STACK: ["n","e","s","w"]
          # Triplicate it
           #  STACK: ["n","e","s","w"],["n","e","s","w"],["n","e","s","w"]
          # Rotate the top one once towards the left
           #  STACK: ["n","e","s","w"],["n","e","s","w"],["e","s","w","n"]
 m+        # Append the top two together
           #  STACK: ["n","e","s","w"],["en","se","ws","nw"]
   m       # Map the strings in the top list to:
    ÉîÄ╪   #  Rotate the string the 1-based index amount of times towards the right
           #   STACK: ["n","e","s","w"],["ne","se","sw","nw"]
^          # Zip; creating pairs with the top two lists
           #  STACK: [["n","ne"],["e","se"],["s","sw"],["w","nw"]]
          # Flatten this list
           #  STACK: ["n","ne","e","se","s","sw","w","nw"]
           # (after which the entire stack is output implicitly as result)

1
17 bytes. This was a fun challenge. I tried it before, but ended up where you did. I think the most you could do from this is 1 byte more, but I couldn't find a shorter way.
maxb

@maxb Ah nice approach. I must admit that those code of block-size X (É and Ä in this case) still confuse me a bit sometimes.. Sometimes I'm not sure when I do or don't have to use those code-blocks. Your m+ doesn't use one for example. But your Ä is a code-block of size 1. I tried mÅî╪ just yet to see what happened, which is why I now understand why there is a code-block of size 1 Ä to begin with. :) ) Thanks for the -3 bytes, though. Still a lot to learn I see.
Kevin Cruijssen

1
Nice explanation! I tried doing a solution without converting it to a list of chars, but the zip command was a bit wonky. For the code blocks, think of them as replacements, used instead of {}. mÅî╪ creates the mapping, but it doesn't have a for-loop inside the mapping. If you write m{î{╪}}, it is perhaps easier to see that the code is "map to: loop <index> times, and rotate the string each loop". The reason why m+ does not have one is that certain commands have implicit 1-byte blocks (map, filter, reduce, etc), but î is not a command meant to be used in combination with a block.
maxb

1
@maxb I indeed knew the code-blocks were a shorter variant of {...}, but I kinda forgot integer{ is a for-loop. :) Now the îÄ╪ makes a lot more sense. Thanks for the explanation!
Kevin Cruijssen

2

CSS, 42 39 bytes

(thanks to a stone arachnid for the revised version)

body:after{content:"N NE E SE S SW W NW"


1
-3 bytes: body:after{content:"N NE E SE S SW W NW"
a stone arachnid

Oh I forgot, that's valid as well ofc, updated :)!
roberrrt-s

2

Seed, 6014 bytes

27 32429737401852232227804295321578416370544555457622262891879921280324727410131817586348135470079420921373938348260737299348550007805068404867624897650263347568409592608258945989033792510474363164709158118555665232935403908551415888090695760298337219819413274977014408722140235669339108001709528995376914900494019798521214727367535169036319615676199584661126257462974800782884967804763256678000063025237472650538076831876942979826335539886276642624472204985016283691316313249488093825552581263195700506490263014623798470563718844847334940964632636436478404543496272112184140337568637349767918641524452384959486975049813859244670160569884744538279036643294867674161431756929550170395739925307134312406291063668809195567313928307910934660574895433141956111513050736041440669472422865481546405020220238818265794921314653725749392385549924210837964649297239381603259476675148489582680939048820717739905271461370132524025785160026801625672272913416389786086946626728842588663673416395169524016926695769334183833366462685756958054189820999370092892855665559717806826530952610964256124463840218293029538229042911551526509745973128558291005365222643503139067010483637086697955919587162384655443959408291567894061028044826636171014388153130769792397282335858985323269310727311039012381122390183102126191168963870116881629339035600546009305431793687183913979054151312200573069395058914262857368132993952655571167118263728070696377852599343989848263167312887211748226689125561718255196655446099711296568221690530717651328503948183228932786503716890383195810396161663632504174142420921735055441162618914957825032056019218584287089599270312541933094119409995775035365862244691419255488688879630142415739738796957474249592086989231999568273454247198389863139439897248192949030226324637037937607004428557202644332945222019553599908855943840883606735602486216245714280716148378430738983808375466562604692991701163078094015860708365913183037140180020776525026891135163345427911749533164462233906885068864798951466382247930357444595606617682531499045805835102155190109668901179666311163071611393282924908189215675892953256826649762594463293867383921972181952997833560371571545190945543033351108064265894854803319008655145213765667074789305055723258530694850418765677462165413557272747961130459219342146615095862014137406489375157766959799291089215740196734079295172946350338663239451562589633216908805028629767462044463310475859283605554743731396818983359527612902567406307270838160926586311672252276690909354125055468912844343806046309796590149977323343332039095076680537362333773750051043281967620781236684580688649899599894791764969639275247700776637892615729757899608628514791667795106390376246890330575517824338764219021396958188958235055290896924249770944905659304681507478975095888248103169710912376599445302527257479613158446721050489233911736089191439017996962182413511012900366501119556105789078275149705515012300827868862038071066912823449506913958912235923323638505757204526506327010926007595704417253684932596231606733027284263178479840785607928320603259662026791082244015829365605451084366715394628351636563955621161378688550003390556445245074739462307110100863024184316465734324401688465928827408449165190271528329602702373730346394803239394173490819727873116531045433457650881080122796159241596543253982402471104065237941729677594379317274541529006952959000152687275974001138315010176843925599438278290218390644740919129323109582279220437886915496736885058271413958305953151184342725824729076581370881383360210631877985352671536000503948280559301633936877162466145026758809907939645467704805892486147550057845773849575278620555906080753862688722846292689494961297512113753414009189522365247542490200336579292488067953461299023326925661887077747288500270026888774635820948696015812357241781814592351848858954139716506111479475207696790949277211077720834891880913260866501916732427370806066035548982017315826213049658915419681842381914237502216614528174237875875738156132703973666564945026254499265910704148825037630761619650949635972980035630316257135212349181639940504547722767898302879234673272154028964478458469466250102554612059368293497511404163963705442187242769706586819405113285219700159125119338601931670779192478917206878107091618448093140705173062420040261126935373689918208815797991761563304607704283868972915636425613833785564679990574095368828308776724486415005128506687942819070129022911666887363253202695416103545769073021185132010920185208632024811337544715055406031297413168802089421761798020616230024290524096396092608042069087607272534874457093977610919233750725135220581682913316085638068663247820037223692942067994551786014033707387642820855601334002540339334606906772532939337779748305357112540312103757754695577077583846897693527091162962000082213332051059005644562753372638247584982354478224403477604356150912451128591138652721098074872513196253790561736352841309810909110001754673250730698454675988798465247376421075019414107337634079281061629221783859449063069175434073835673063716565555614782886016441814199915418848976070834414782427725187820926042778984081922550398210353288229598805397201850487997254871012213762289412828417039945896819359898337616122446201299182152276549340911589671291124887672310931868023491872685227548726494469798568145715500153324646857181224645073236602344526749192704938665584870007079941922775292601106345725659322322536675461008337648982039319953181733660980694781559207671567197161027796266390879206526082137700937056380629087949633487181507979286568656291044492869916694352395542638882544967807857391058161838343109606346401310155771709714142586733985703451391374159045025205718989407293651441039802247981386993858491342422355232055341447145969376687615001834650283116652856369804298047720786536278306210551862061566639283704928517998916884505819581251906693306116531467413995747910736025576089721150597919824878333808115757216261812226145636769545796913912159437533454858286778214791559458862216426856243544801486923659355580455048265633089421966932180992

Generates following befunge program:

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

2

Hodor, 177 bytes

hodor.hod("HoOodoOorhodor  HoOodoOorhodor HooodorrHodor  HooodorrHodor  HODOR?!? HooodorrHodor  HODOR?!?  HODOR?!? Hooodorrhodor  Hooodorrhodor  HoOodoOorhodor Hooodorrhodor ");

Try it online!


2

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"?



Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.