text:
There are known knowns
Former US Secretary of Defense, Donald Rumsfeld, famously popularized the phrase "known knowns." Here we're going to distill his remarks into a four-line stanza.
Specifically, output this text:
known knowns
known unknowns
unknown knowns
unknown unknowns

Capitalization doesn't matter (for example, Known unKnowns is fine), and a single trailing newline is acceptable, but no other formatting changes are allowed. That means a single space between the words, and either LF (59 bytes) or CR/LF (62 bytes) between the lines.
Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Can anyone explain why this has got so many downvotes? For me it is a reasonable challenge and has encouraged a variety of answers in a mixture of languages.

@ElPedro The reason behind the many downvotes is a known unknown

May we return a matrix or a list of strings?

@Adám A list of four strings would be OK, as that's still preserving the space between words; but, unless you're doing a matrix of every character including the spaces, matrices are not OK.

Related :^D

Are the trailing spaces intentional?

@user202729 There aren't any trailing spaces.

I don't think Rumsfeld ever said "unknown knowns", although others have extended it as "things we know but refuse to acknowledge"

Python 2, 54 52 bytes
-2 bytes thanks to xnor

k='unknowns'
for i in 8,6,2,0:print k[i/3:7],k[i%3:]

Try it online!
The results from the / and % will be [[2, 2], [2, 0], [0, 2], [0, 0]] that will be the starting indexes, removing the un when 2, keeping the string unaltered when 0

If you let k be 'unknowns', you can correct with k[i/3:7] and save two bytes.

Vim 28 25 bytes
This is my first Vim answer, any golfing tips are welcome.
2iunknown ␛rsY3P2xw.+.jw.

Thank you Lynn for writing the python script to make that fantastic animation.
This can also be run by V Try it Online!
Also 25:
2iknown ␛rsY3pwiun␛+.+.w.

I only managed to find another 25: 2iunknown ␛rsYPw2x2YP2xj. or a slight variation 2iunknown ␛rsYPw2x2YPⓋjlx (Ⓥ = Ctrl-V).

@Lynn Nice, I tried Ctrl-V but got something longer.

bash, 36 bytes
printf %s\\n {,un}known\ {,un}knowns

other solutions
36
eval echo\ {,un}known\ {,un}knowns\;

37
eval printf '%s\\n' \{,un}known{\\,s}

38
eval eval echo\\ \{,un}known{\\,'s\;'}

41
x=\\\ {,un}known;eval "eval echo$x$x\s\;"

45
x='\ {,un}known' e=eval;$e "$e echo$x$x\s\;"
x='\ {,un}known' e=eval\ ;$e"$e\echo$x$x\s\;"

if leading newline and extra space were accepted  31 bytes :
echo '
'{,un}known\ {,un}knowns

for those wondering what kind of sorcery is this (like myself): this is bash brace expansion

… even better explained on bash-hackers.org, and you can Try it online!.

If in doubt, put the whole answer in a code block

reworded, the invalid input at the end

05AB1E, 13 12 bytes
Saved 1 byte thanks to Erik the Outgolfer (avoid closing string)
„Š¢—‚#D's«â»

Try it online!
Explanation
„Š¢—‚           # push the string "known unknown"
     #          # split on spaces
      D         # duplicate
       's«      # append "s" to each
          â     # cartesian product
           »    # join on newline

“Š¢—‚“ -> „Š¢—‚

@EriktheOutgolfer: Oh yeah, only 2 words. Thanks!

Bahhh... why didn't I look first? Same answer.

CJam (26 25 bytes)
"unknown"_2>\]2m*{S*'sN}%

Online demo
Cartesian product of ["known" "unknown"] with itself, then each element joined with space and suffixed with s and a newline.
Thanks to Erik for a one-byte saving.

R, 52 51 50 bytes
cat(gsub(1,"known","1 1s
1 un1s
un1 1s
un1 un1s"))

Try it online!
Surprisingly short substitution and print commands make this an actually competitive R answer in a string challenge!
Even if it's super boring. Mildly more interesting now, and with a byte saved thanks to J.Doe!
Saved another byte thanks to this answer, also by J.Doe!

Haskell, 60 58 53 51 bytes
f<$>l<*>l
f x y=x++' ':y++"s"
l=["known","unknown"]

Try it online!
Yields a list of lines as was recently allowed. Thanks to @firefrorefiddle for pointing out.
-2 bytes thanks to cole.

58 byte version:
f=<<"? ?s\n? un?s\nun? ?s\nun? un?s"
f '?'="known"
f c=[c]

Try it online! Yields a single string.

Your 60 byte version is actually a 53 byte version because you can remove unlines because "A list of four strings would be OK, as that's still preserving the space between words;" (Comment to original question).

51 bytes combining your approach with @PeterTaylor's

Retina, 33 32 bytes
Saved 1 byte using an intermediate printing approach from Leo.

 ¶u

knowns
u
 un
:`s

m`^
un

Try it online!
Explanation

 ¶u

Turns the non-existent (i.e. empty) input into the string on the second line. That one seems pretty weird, but these characters are codes for the stuff that goes between two instances of known[s] on the first two lines of the result. Space and linefeed are just themselves and u is  un.

knowns

Now we insert knowns at every position (i.e. at the beginning, end, and between every pair of characters).
u
 un

We decode the u.
:s

Then we get rid of the ss in front of spaces, i.e. those in the first half of each line, and print the result.
m`^
un

And finally we prepend un to both lines and print the result again.
This beats the trivial approach of just using a placeholder for known by 4 bytes, but not Neil's more efficient implementation of that approach.

Retina, 33 32 bytes

 s¶ uns¶un s¶un uns
 |s
known$&

Try it online! Edit: Saved 1 byte thanks to @ovs. Explanation: This is almost the trivial approach of using a placeholder for known, except here I simply insert it before each space or s, which saves 3 4 bytes.

32 bytes

You can improve this by printing halfway

@Leo using that you don't even need the |s approach any more: https://tio.run/##K0otycxL/P@fK1shu/jQtmyF0rzsYi6rhGyu7Lz88jyu3IQ4rtK8//8B

C# (.NET Core), 54 bytes
v=>@"z zs
z unzs
unz zs
unz unzs".Replace("z","known")

Try it online!

PHP, 55 51 47 bytes
<?=strtr("1 1s
1 01s
01 1s
01 01s",[un,known]);

try it online

Do you need opening tags for php entries?

@Josiah I need something to print the result; <?= is the shortest option.

Shakespeare Programming Language, 1021 1012 993 bytes
-19 bytes thanks to Joe King!
,.Ajax,.Ford,.Page,.Act I:.Scene I:.[Exeunt][Enter Ajax and Ford]Ajax:Am I nicer a big cat?If sois the remainder of the quotient betweenI the sum ofa cat a big cat worse a big cat?If notlet usScene V.You be the sum ofa fat fat fat pig the cube ofthe sum ofa cat a big big cat.Speak thy.You be the sum ofyou the sum ofa cat a fat fat fat pig.Speak thy.Scene V:.[Exit Ajax][Enter Page]Page:You be the product ofthe sum ofa cat a big big cat the sum ofa pig a big big big big cat.Speak thy.You be the sum ofyou the sum ofa cat a big cat.Speak thy.Ford:You be the sum ofI a cat.Speak thy.You be the sum ofyou a big big big cat.Speak thy.Page:Speak thy.You be the sum ofyou the sum ofa cat a big big cat.Is the remainder of the quotient betweenAjax a big cat worse a cat?If soyou big big big big big cat.Speak thy.If solet usScene X.You be twice the sum ofa cat a big big cat.Speak thy.Scene X:.[Exit Page][Enter Ajax]Ford:You be the sum ofyou a cat.Be you worse a big big big cat?If solet usAct I.

Try it online!

You cam remove the spaces after some multi-word operators like the sum of

Really? Huh, that's a lot of shortest-representations-of-numbers I have to recalculate. Thanks.

APL (Dyalog), 64 47 35 bytes
⍪,∘.{⍺,' ',⍵,'s'}⍨k('un',k←'known')

Try it online!
How?
k←'known' - k is "known"
k('un',k←'known') - "known" "unknown"
∘....⍨ - outer product with itself
    {⍺,' ',⍵,'s'} - with the function that formats the args as {⍺} {⍵}s
, - smash the product table into vector
⍪ - separate to columns

33 bytes (+ fixing the bad output format)

@dzaima 31

C (gcc),  79   78  76 bytes
Thanks to @Justin Mariner for golfing one byte!
f(){printf("%s %1$ss\n%1$s un%1$ss\nun%1$s %1$ss\nun%1$s un%1$ss","known");}

Try it online!

I think this can be one byte less if you use %1$s and get rid of i: Try it online!

Java 8, 56 55 bytes
v->" s\n uns\nun s\nun uns".replaceAll(" |s","known$0")

-1 byte thanks to @SuperChafouin.
Explanation:
Try it here.
v->                         // Method with empty unused parameter
  " s\n uns\nun s\nun uns"  //  Literal String
   .replaceAll(" |s",       //  Replace all spaces and "s" with:
     "known                 //   Literal "known"
           $0")             //   + the match (the space or "s")
                            // End of method (implicit / single-line return-statement)

Okay, I gotta ask... why \r? ^^'

@OlivierGrégoire Woops.. ;p

You can win one byte with v->" s\n uns\nun s\nun uns".replaceAll(" |s","known$0")

Perl 6, 45 bytes
$_='known';.say for [X](($_,"un$_")xx 2)X~'s'

Try it
Expanded
$_ = 'known';

.say                # print with trailing newline the value in topic variable ｢$_｣

  for               # do that for each of the following

    [X](
      ($_, "un$_")  # ('known','unknown')
        xx 2        # list repeated twice
    ) X~ 's'        # cross using &infix:«~» with 's' (adds ｢s｣ to the end)

The [X](…) part generates
(("known","known"),("known","unknown"),("unknown","known"),("unknown","unknown")).Seq

Then using X~ on it coerces the inner lists into a Str (because of the &infix:«~» operator), which doing so adds a space between values.
("known known", "known unknown", "unknown known", "unknown unknown").Seq

Then each is joined with an s
("known knowns", "known unknowns", "unknown knowns", "unknown unknowns").Seq

41 bytes

Haskell, 57 52 bytes
id=<<id=<<mapM(\s->[s,"un"++s])["known ","knowns\n"]

Try it online!

49 bytes with an alternate output of list

@cole: the output format is very strict, so I think a list of strings in not valid.

the other haskell answer does it, seems like the OP okayed that format.

Jelly, 15 bytes
“ṿ1“ŒwƘ»pż€⁾ sY

Try it online!

:( The compressed version is 29 bytes

Perl 5, 33 bytes
Disclaimer: I didn't realise that brace expansion was possible within the <...> operator (learned thanks to @Grimy's answer!) and the using the clever expansion trick from @NahuelFouilleul's amazing bash answer, I was able to build this solution. I will happily remove this at either of their request.
print<"{,un}known {,un}knowns$/">

Try it online!

Perl 5, 42 bytes
41 bytes code + 1 for -p.
s//K Ks
K unKs/;s/K/known/g;$\=s/^/un/gmr

Try it online!

Perl 5, 45 bytes
Tried to come up with an alternative, but couldn't make it shorter... Thought it was different enough to warrant adding anyway.
print"un"x/[3467]/,known,$_%2?"s
":$"for 0..7

Try it online!

Ruby, 53 50 bytes
$><<"a as
a unas
una as
una unas".gsub(?a,"known")

Replace \n with a literal newline.

@ValueInk Done.

Husk, 14 bytes
OΠṠemhw¨ṅW∫ḟωμ

Try it online!
Explanation
OΠṠemhw¨ṅW∫ḟωμ
       ¨ṅW∫ḟωμ    The compressed string "knowns unknowns"
      w           Split on spaces ["knowns","unknowns"]
   e              Make a list with:
    mh             this list with the last letter dropped from each word
  Ṡ                and this same list
                  [["known","unknown"],["knowns","unknowns"]]
 Π                Cartesian product [["known","knowns"],["unknown","knowns"],["known","unknowns"],["unknown","unknowns"]]
O                 Sort the list [["known","knowns"],["known","unknowns"],["unknown","knowns"],["unknown","unknowns"]]
                  Implicitely print joining with spaces and newlines

Haskell, 71 66 56 54 bytes
(<*>).map((++).init)<*>map(' ':)$["knowns","unknowns"]

Thanks to @Leo for -3 bytes!
Note: In the question's comments, the o.p. said that returning a list of strings is okay
Try it here.

This is great and I can't even understand it, but the part from your second fmap onwards can be shortened to map(' ':) :)

@Leo Thanks! Haha, I'm not even sure I understand it anymore

No need to give the function a name, so you can drop the f=.

6502 machine code (C64), 48 bytes
00 C0 A9 37 85 FB A9 73 4D 2B C0 8D 2B C0 A9 0D 4D 2C C0 8D 2C C0 A9 26 90 02
E9 02 A0 C0 20 1E AB 06 FB D0 E1 60 55 4E 4B 4E 4F 57 4E 53 0D 00

Online demo
Usage: sys49152

How it works
The trick here is to use a "loop counter" for 8 iterations where bits 7 to 1 of the initial value are 1 for unknown(s) and 0 for known(s) in one iteration. This counter is shifted to the left after each iteration (shifting the leftmost bit into the carry flag) and bit 0 is initially 1 so we know we're finished once the last bit was shifted out. In the first iteration, known is printed because when calling the program, the carry flag is clear.
In each iteration, the end of the string is toggled between <space> and s<newline>.
Here's the commented disassembly listing:
         00 C0            .WORD $C000    ; load address
.C:c000  A9 37            LDA #$37       ; initialize loop counter ...
.C:c002  85 FB            STA $FB        ; ... as 0011 0111, see description
.C:c004   .loop:
.C:c004  A9 73            LDA #('s'^' ') ; toggle between 's' and space
.C:c006  4D 2B C0         EOR .plural
.C:c009  8D 2B C0         STA .plural
.C:c00c  A9 0D            LDA #$0D       ; toggle between newline and 0
.C:c00e  4D 2C C0         EOR .newline
.C:c011  8D 2C C0         STA .newline
.C:c014  A9 26            LDA #<.knowns  ; start at "known" except
.C:c016  90 02            BCC .noprefix  ; when carry set from shifting $fb:
.C:c018  E9 02            SBC #$02       ; than start at "un"
.C:c01a   .noprefix:
.C:c01a  A0 C0            LDY #>.knowns  ; high-byte of string start
.C:c01c  20 1E AB         JSR $AB1E      ; output 0-terminated string
.C:c01f  06 FB            ASL $FB        ; shift loop counter
.C:c021  D0 E1            BNE .loop      ; repeat if not 0 yet
.C:c023  60               RTS            ; done
.C:c024   .unknowns:
.C:c024  55 4E           .BYTE "un"
.C:c026   .knowns:
.C:c026  4B 4E 4F 57 4E  .BYTE "known"
.C:c02b   .plural:
.C:c02b  53              .BYTE "s"
.C:c02c   .newline
.C:c02c  0D 00           .BYTE $0d, $00

PowerShell, 46 44 bytes
' s
 uns
un s
un uns'-replace' |s','known$&'

Try it online!
(Almost) simple string replacement. Uses Neil's approach to trim two bytes. Thanks to Martin for pointing that out.
Sadly, it's shorter than the more interesting cross-product method by three five three bytes:
PowerShell, 49 47 bytes
($a='known','unknown')|%{$i=$_;$a|%{"$i $_`s"}}

Try it online!

Neil's approach saves 2 bytes.

@MartinEnder Right, good call. Thanks!

Batch, 66 bytes
@set s= in (known unknown)do @
@for %%a%s%for %%b%s%echo %%a %%bs

Alternative answer, also 66 bytes:
@for %%a in (k unk)do @for %%b in (k unk) do @echo %%anown %%bnowns

Of course, nested loops, haven't thought of that... good job!

T-SQL, 56 54 bytes
PRINT REPLACE('1 1s
1 un1s
un1 1s
un1 un1s',1,'known')

SQL supports line breaks inside string literals, so similar to some other languages already posted.
EDIT: Slightly longer (82 bytes), but a bit more clever:
SELECT k+s+k+p+k+s+u+p+u+s+k+p+u+s+u+p
FROM(SELECT'known'k,' 's,'unknown'u,'s
'p)t

EDIT 2: My favorite so far, using a cross-self-join from a derived table (79 bytes):
WITH t AS(SELECT'known'a UNION SELECT'unknown')
SELECT z.a+' '+t.a+'s'FROM t,t z

EDIT 3: Changed the replacement character from 'x' to 1, which lets me remove the quotes around it and save 2 bytes, since REPLACE does an implicit conversion to string.

Haxe, 71 bytes
(?x)->[for(a in x=["","un"])for(b in x)a+'known ${b}knowns'].join("\n")

Try it online!

Jq 1.5, 47 bytes
"K Ks
K unKs
unK Ks
unK unKs"|gsub("K";"known")

Try it online!

Javascript 66 54 53 50 bytes
_=>` s
 uns
un s
un uns`.replace(/ |s/g,'known$&')

History

saved 12 bytes thanks to @someone (explicit usage of "un" in the main string)
saved 1 byte thanks to @ThePirateBay (split..join instead of replace)
saved 3 bytes thanks to @Neil (better replace())

I think it would be shorter to add un in the string itself

you're totally right, a shame that it dumbs the solution so much down though.

Is the space after the comma needed?

nope, just noticed that too.

BTW I think you can save 4 bytes by porting my Retina answer.

Using split..join instead of replace saves one byte.

@Neil i have no idea about Retina at all

I meant by removing the 0s and using .replace(/ |s/g,'known$&') (which now only saves 3 bytes).

interesting, editting the answer, thanks :)

ReRegex, 38 bytes
a/known/a as\na unas\nuna as\nuna unas

Try it online!

I'm seeing this language for the first time, but a/known / z/s\n/aazaunazunaazunaunaz seems to work for 36 bytes.

Bash, 60 57 54 52 bytes
b=${a=known}s;echo "$a $b
$a un$b
un$a $b
un$a un$b"

Try it online!

L3viathan: -3
Dom Hastings: -3
manatwork: -2

Thank you guys!

57 bytes if you replace the "\n" with a literal newline

@L3viathan 54 even, as you won't need the -e after echo! :)

a=known;b=${a}s → b=${a=known}

@manatwork you meant b=${a=known}s, but I got it – thanks!

Vim, 28 keystrokes
iknown <C-n>s<CR><C-X><C-l><S-Left>un<Esc>o<C-p><Left> <C-n><Esc>o<C-p><C-p> <C-p>s

Also 28:
iknown <C-n>s<Esc>qqo<C-X><C-l><S-Left>un<Esc>qo<C-p><Left> <C-n><Esc>@q

C (gcc), 70 66 bytes
Thanks to @l4m2 for -4 bytes!
f(i){for(i=8;i--;)printf("unknown%s"+(i>4|i==2)*2,i%2?" ":"s\n");}

Try it online!

In reverse f(i){for(i=8;i--;)printf("unknown%s"+(i>4|i==2)*2,i%2?" ":"s\n");}

Suggest L"ੳ "+i%2 instead of i%2?" ":"s\n"

Haskell, 49 bytes
unwords<$>mapM(\s->[s,"un"++s])["known","knowns"]

Try it online!

C, gcc, 64 bytes
c="unknown";f(i){for(i=4;i--;)printf("%s %ss\n",i&2|c,i%2*2+c);}

Seems doesn't work on TIO, but works fine on my coputer

ed, 52 bytes
a
known knowns
.
,t1
2s/ k/ unk/
,t2
3,4s/^k/unk/
w

Try it online!

Python 3, 69 bytes
k=['known','unknown']
for i in range(4):print(k[i//2]+' '+k[i%2]+'s')

Welcome to PPCG!

thanks @AdmBorkBork !

Underload, 58 bytes
((:^)(s
)( )(known):(un)~*):^!:S~SSS^~S~SSS^S~SSS^~!:S~SSS

Uses a simple lookup table with a lot of Ss.
Try it Online!

Wolfram Language (Mathematica), 46 bytes
Outer[Print[#,a=nown," ",#2,a,s]&,b={k,unk},b]

Try it online!

ink, 39 bytes
-(i){||un}known {&|un}knowns
{i<10:->i}

Try it online!

Octave, 55 bytes
[{'un','known',[115,10],32}{'bdbcbdabcabdbcabdabc'-96}]

Try it online!
Explanation:
First, we create a cell array with four strings: un, known, s\n and . Then we create a string bdbcbdabcabdbcabdabc that becomes the appropriate indices when we subtract 96: a=1, b=2, c=3, d=4. We index the cell array using cell indexing {}, and concatenate the result using brackets [].

The following is one byte longer than the output itself.
printf(strrep(', ,s\n, un,s\nun, ,s\nun, un,s',',','known'))

IBM/Lotus Notes Formula, 78 bytes
@ReplaceSubstring("a as,a bas,ba as,ba bas";"a":"b":",";"known":"un":@Newline)

Not the shortest but actually shorter than just hard coding the strings in @Formula.
Formula language allows lists as the from and to parameters to @ReplaceSubstring. Just a shame that @ReplaceSubstring itself costs 17 bytes and @Newline costs 4 more than "\n".

Batch, 78 bytes
@set a=known
@echo %a% %a%s&echo %a% un%a%s&echo un%a% %a%s&echo un%a% un%a%s

Quite hard to golf, everything non-trivial I tried so far just makes it longer.

V, 25 bytes
Two solutions, both 25 bytes
2iunknowns |exÄwxxäj2xj.

Try it online!
Hexdump:
00000000: 3269 756e 6b6e 6f77 6e73 201b 7c65 78c4  2iunknowns .|ex.
00000010: 7778 78e4 6a32 786a 2e                   wxx.j2xj.

And
2iunknown Äwxxäj2xj.Î$rs

Try it online!
Hexdump:
00000000: 3269 756e 6b6e 6f77 6e20 1bc4 7778 78e4  2iunknown ..wxx.
00000010: 6a32 786a 2ece 2472 73                   j2xj..$rs

J, 39 bytes
echo@;@,"1//' s'|.@;"0/(;'un',])'known'

Try it online!
Here's another one, that I'll explain instead (53 chars):
;"1((<<<2)&{,],48&A.,:n)({.,' ';n=.'un';])'known';'s'

|
                        ({.,' ';n=.'un';])'known';'s'

Yields ["known", " ", "un", "known", "s"] and defines n that adds "un" in front. Then for each of the 4 lines respectively we
    (<<<2)&{                     Remove "un", the 2nd string
             ]                   Do nothing
               48&A.             Move "un" to the front
                      n          Add "un"
;"1                              Smash the lines.

2,0,1,3,4 is #48 in the alphabetically sorted list of permutations of 0,1,2,3,4. I've no idea how it's implemented.

The permutations is ordered by the permutation/factorial base of the input number 48, I suppose

Also, as it stands, this is neither a full program (which would use echo) or a function/verb. Adding echo to the beginning of your program or somehow make this tacit would fix this

@Conor O'Brien oh, fair enough

Pyth, 28 bytes
-1 byte thanks to hakr14.
jm+j;d\s^_c"unknown known"d2

Try it here!

You can save a byte by just using a normal string.

whoops, another byte to save: _c"unknown known"d=>c"known unknown"d

///, 35 bytes
/2/un1//1/known/1 1s
1 2s
2 1s
2 2s

Try it online!

K (oK), 41 bytes
Solution:
(1_',/x,/:\:x:(" known";" unknown")),'"s"

Try it online!
Explanation:
This still feels clunky, but this is the shortest version yet:
(1_',/x,/:\:x:(" known";" unknown")),'"s" / the solution
(                                  ),'"s" / append "s" to each left
              (" known";" unknown")       / 2-item list of " known" and " unknown"
            x:                            / save as variable x
      x,/:\:                              / x concatenate each right (/:) with each left (\:)
    ,/                                    / flatten lists
 1_'                                      / drop first item from each list (ie drop the leading whitespace)

Notes:
Other versions:
/ 49 bytes, just join each right/each left and flatten
,/("known";"unknown"),/:\:(" knowns";" unknowns")

/ 43 bytes, try to be smarter building the known/knowns
,/2 0_/:\:"unknown ",/:("";"un"),\:"knowns"

Japt -R, 22 bytes
`kÍ5 unkÍ5`¸
ïUm+'s)m¸

Test it

That -R in the input should be included in your code length.

@StephenLeppik, not any more

Ah, haven't been paying enough attention to Meta then :/ sorry about that.

Pyth, 24 bytes
jm+j;d\s^_>B"unknown"2 2

Try it online here.
jm+j;d\s^_>B"unknown"2 2
            "unknown"      String literal
          >          2     Remove the first two letters
           B               Pair the above with the original string - ["unknown", "known"]
         _                 Reverse
        ^              2   Cartesian product with itself
 m                         Map each pair, as d, using:
   j;d                       Join on spaces
  +   \s                     Append "s"
j                          Join on newlines, implicit print

Burlesque - 29 bytes
"unknown"J2.-CLJcp{wd's_+}muQ

"unknown"J                     duplicate
          2.-                  drop 2
             CL                collect stack
               J               duplicate
                cp             cross product
                  {            begin block
                   wd          words
                     's_+      append `s`
                         }     end block
                          mu   map unlines
                            Q  pretty print

Try it online.
Alternate versions:
"known unknown"wdJcp{wd's_+}muQ

MathGolf, 23 19 18 bytes
4♀*(╦_╢Ñ▌]■{ u's+p

Try it online!
Explanation
I really need some base-250 integers
4♀*(                 Push 4, push 100, multiply, decrement (resulting in 399)
    ╦                Fetch dictionary word with index 399
     _               Duplicate
      ╢Ñ             Push "un"
        ▌            Prepend to TOS
         ]           Wrap stack in array
          ■          Cartesian product with itself
           {         For-each
             u       Join with space (space character is before the "u")
              's+    Add "s"
                 p   Print

I was thinking using n, but it seems to just print the newlines?

@JoKing I'm not completely satisfied with my n implementation. For a list, it joins it with newlines, but otherwise it just outputs a newline with python's print. That makes it behave strangely in for loops.

Ah, I had assumed that it added a newline character to the stack

@JoKing That's probably what I'll change it to, I'll just have to make sure that it doesn't break any unit tests.

JavaScript, 78 bytes
This is my first-ever attempt at solving a code golf, so all suggestions welcome!

console.log(k=(u="unknown").substr(2),k+(s="s")+(n="\n")+k,u+s+n+u,k+s+n+u,u+s)

Explanation
Step 1: k=(u="unknown").substr(2). The u="unknown" evaluates to "unknown". A substring of this, from char #2 until the end of the string, is then assigned to variable k. This whole thing evaulutes to the outermost assignment, "known", which is the first parameter to console.log.
Step 2: Next is a ,. Each parameter to console.log is printed with a space in between, so a , represents a space in the output. The current output is "known ".
Step 3: k+(s="s") evalutates to "knowns", and at the same time assigns "s" to the variable s, to be used as a shorthand for later. The current output is "known knowns"
Step 4: +(n="\n")+k. We append a newline to this, and store the newline character as a shorthand for later. We also append k. The current output is "known knowns{newline}known".
Step 5: ,u+s+n+u,k+s+n+u,u+s) the rest is very simple: just appending k, s, and u, using ,s for spaces, to spell out the rest of the output.
Like I said, this is my first-ever code  golf, so I would appreciate any tips/tricks.

Dart, 62 61 bytes
g({s='known'})=>"$s $s\s\n$s un$s\s\nun$s $s\s\nun$s un$s\s";

Try it online!

Stax, 15 bytes
┬τj%7↕▬α0▄╘δ₧▲\

Run and debug it

Split compressed string "known unknown"
Self Cross-product to produce all pairs
For each, join with space, and append "s".

Wolfram Language (Mathematica), 57 bytes
StringReplace["K Ks
K unKs
unK Ks
unK unKs","K"->"known"]

Try it online!

hehehe... unk :D

Vyxal j, 15 bytes, (@lyxal)
`»² ¢λ`⌈:ẊvṄ\s+

Try it Online!
Vyxal j, 18 bytes
`»²`:‛unp":\svpẊvṄ

Try it Online!
Vyxal has really improved my productivity, I wrote this in just 2 minutes.
`»²`    Dictionary compressed string "known"
:         Duplicate ^
‛un     Two byte string `un`
p         Prepend un to known
"          Pair the two words as a list
:          Duplicate ^
\s       Single byte char "s"
vp       Vectorised append to the duplicated lost
Ẋ         Take cartesian product of two lists
vṄ      Vectorised join by space in each ordered pair of the ^
            (Implicit join with newlines, by j flag)

Try it Online! for 15

Zsh, 27 bytes
>{,un}known\ {,un}knowns
ls

Attempt This Online!
Or, a slightly cheaty version which
outputs to a file called known knowns:
Zsh, 26 bytes
ls>{,un}known\ {,un}knowns

Attempt This Online!


text:
Find the greatest line
You will be given a 2-D array A of integers, and a length N. Your task is to find within the array the straight line (horizontal, vertical or diagonal) of N elements that yields the highest total sum, and return that sum.
Example
 N = 3, A =
 3    3    7    9    3
 2    2   10    4    1
 7    7    2    5    0
 2    1    4    1    3

This array has 34 valid lines, including
 Vertical
 [3]   3    7    9    3
 [2]   2   10    4    1
 [7]   7    2    5    0
  2    1    4    1    3       [3,2,7] = 12
 Horizontal
  3    3    7    9    3
  2    2   10    4    1
  7    7   [2]  [5]  [0]
  2    1    4    1    3       [2,5,0] = 7
 Diagonal
  3    3   [7]   9    3
  2    2   10   [4]   1
  7    7    2    5   [0]
  2    1    4    1    3       [7,4,0] = 11

The maximum line is
 3    3    7   [9]   3
 2    2  [10]   4    1
 7   [7]   2    5    0
 2    1    4    1    3        [7,10,9] = 26

Note: lines may not wrap around the edges of the array.
Inputs

A X by Y 2-D array A, with X,Y > 0. Each element of the array contains an integer value which may be positive, zero or negative. You may accept this array in an alternative format (e.g. list of 1-D arrays) if you wish.
A single, positive integer N, no greater than max(X,Y).

Output

A single value representing the maximal line sum that can be found in the array. Note that you do not need to provide the individual elements of that line or where it is located.

Test cases
N = 4, A =
-88    4  -26   14  -90
-48   17  -45  -70   85
 22  -52   87  -23   22
-20  -68  -51  -61   41
Output = 58

N = 4, A =
 9    4   14    7
 6   15    1   12
 3   10    8   13
16    5   11    2
Output = 34

N = 1, A =
 -2
Output = -2

N = 3, A =
1    2    3    4    5
Output = 12

N = 3, A =
-10   -5    4
 -3    0   -7
-11   -3   -2
Output = -5

Could you add a test case where the resulting output is negative? Like [[-10, -5, 4],[-3, 0, -7],[-11,-3,-2]] -> -5 (4 + -7 + -2)

@KevinCruijssen Sure, added

By the way: all answers with an explanation will gain an upvote from me, but otherwise I have no way of judging languages that I'm not familiar with (and that's most of them).

Jelly, 15 bytes
,ZṚ¥;ŒD$+⁹\€€FṀ

Try it online!
How it works
,ZṚ¥;ŒD$+⁹\€€FṀ  Main link. Left argument: M (matrix). Right argument: n (integer)

 ZṚ¥             Zip/transpose and reverse M. This is equivalent to rotating M 90°
                 counterclockwise.
,                Pair M and the result to the right.
    ;ŒD$         Append the diagonals of both matrices to the pair.
        +⁹\€€    Take the sums of length n of each flat array.
             FṀ  Flatten and take the maximum.

Nice abuse of ¥ there...

For future (new) users: $ creates a monad from ZṚ, while ¥ creates a dyad from ZṚ which returns the result of the same function (rotate 90 CCW) applied on its left operand. Which matches the pattern + × and evaluate v+(λ×ρ) (it is v = v , (M ZṚ¥ n) in this case). However just use $ doesn't work because there is no + F pattern in dyadic chain.

Wolfram Language (Mathematica), 73 bytes
Max[Tr/@Join[#,#,{#,Reverse@#}]&/@Join@@Partition[#2,{#,#},1,1,-∞]]&

Try it online!
How it works
Takes first N and then the matrix A as input.
Join@@Partition[#2,{#,#},1,1,-∞] finds every N by N submatrix of the matrix A, padded with -∞ where necessary to ensure that lines running out of the grid will be out of the running.
For each of those blocks we compute Tr/@Join[#,#,{#,Reverse@#}]: the trace (i.e. sum) of each row, the trace (i.e. sum) of each column, the trace (actually the trace, for the first time in the history of Mathematica code golfing) of the block, and the trace of the block reversed. # is Transpose@#.
Then we find the Max of all of these.

For most inputs, the 57-byte Max@BlockMap[Tr/@Join[#,#,{#,Reverse@#}]&,#2,{#,#},1]& also works. But we need to pad with -∞ to handle cases where A has fewer than N rows or columns, and BlockMap doesn't support padding.

For TIO-friendly version (Mathematica script mode): The character U+F3C7 (\[Transpose]) can be typed in as \:f3c7.

Also I believe it is not the first time Tr is used as trace.

Thanks! And when I'm not exaggerating, I'm sure using Tr as the trace of a matrix has come up before, but it's still rare and surprising.

I know I've said that before, but non-ASCII code should work just fine now. Try it online!

Is that new? I feel like I tried ∞ an hour ago and it didn't work, but maybe I just made a mistake.

It didn't work an hour ago. I'm using a workaround to make TIO's Mathematica accept UTF-8 code, but that broke with the update to 11.2.0. I just fixed it again.

Well, thank you for making the workaround work: we all appreciate it, as do our byte counts.

If anything else doesn't work as it should, please feel free to leave me a message in http://talk.tryitonline.net.

Mathematica, 135 123 bytes
Max[(s=#;r=#2;Max[Tr/@Partition[#,r,1]&/@Join[s,s~Diagonal~#&/@Range[-(t=Tr[1^#&@@s])+2,t-1]]])&@@@{#|#2,Reverse@#|#2}]&

Try it online!

Some optimizations: Diagonal[s,#] to s~Diagonal~#, and {{Transpose@#,#2},{Reverse@#,#2}} to {#|#2,Reverse@#|#2}. (The unprintable is U+F3C7 = \[Transpose]; TIO doesn't seem to like this, though. Alternative: {Transpose@#|#2,Reverse@#|#2})

@JungHwanMin It's not TIO's fault, Mathematica on TIO is run in script mode, which only support ASCII. You need to type \[Transpose] or \:f3c7 (at least the latter is shorter than Thread@) However if the answer is Mathematica REPL (not Mathematica script) you can assume the 3-byte solution.

@user202729 Thanks, didn't know!

Jelly, 16 bytes
µ;Z;Uµ;ŒDðṡ€ẎS€Ṁ

Try it online!

Wow our solutions are nearly identical... Mine was µ;Z;UŒD$;ŒDṡ€⁴ẎS€Ṁ

@Mr.Xcoder Oh wow cool :P

JavaScript, 151 129 bytes
a=>n=>a.map((l,x)=>l.map((v,y)=>[...'01235678'].map(d=>m=(g=i=>i--&&g(i)+(a[x+d%3*i-i]||[])[y+i*~-(d/3)])(n)>m?g(n):m)),m=-1/0)|m

Curry function takes two arguments, first one is an array of array of numbers, second one is a number.
Thanks to Arnauld, save 20+ bytes.

f=

a=>n=>a.map((l,x)=>l.map((v,y)=>[...'01235678'].map(d=>m=(g=i=>i--&&g(i)+(a[x+d%3*i-i]||[])[y+i*~-(d/3)])(n)>m?g(n):m)),m=-1/0)|m

N = <input id="N" type="number" min="1" value="3" />

A = <textarea id="A" style="width: 400px; height: 200px;"> 3    3    7    9    3
 2    2   10    4    1
 7    7    2    5    0
 2    1    4    1    3
</textarea>

<input value="Run" type="button" onclick="O.value=f(A.value.split('\n').filter(x=>x.trim()).map(x=>x.trim().split(/\s+/).map(Number)))(+N.value)" />

Result = <output id="O"></output>

1/s instead of s==s should work as expected.

Getting rid of both eval's: 130 bytes

@Arnauld Thanks. And change (s=(g=...)(n))>m?s:m to (g=...)(n)>m?g(n):m save 1 byte.

Jq 1.5, 211 bytes
def R:reverse;def U:[range(length)as$j|.[$j][$j:]]|transpose|map(map(select(.))|select(length>=N));def D:U+([R[]|R]|U|map(R)[1:]);[A|.,transpose,D,(map(R)|D)|.[]|range(length-N+1)as$i|.[$i:$i+N]]|max_by(add)|add

Expects input in N and A, e.g:
def N: 3;
def A: [
  [ 3, 3,  7, 9, 3 ],
  [ 2, 2, 10, 4, 1 ],
  [ 7, 7,  2, 5, 0 ],
  [ 2, 1,  4, 1, 3 ]
];

Expanded
def chunks:      .[] | range(length-N+1) as $i | .[$i:$i+N] ;
def flip:        [ reverse[] | reverse ] ;
def upperdiag:   [ range(length) as $j | .[$j][$j:] ] | transpose | map(map(select(.))|select(length>=N)) ;
def lowerdiag:   flip | upperdiag | map(reverse)[1:] ;
def diag:        upperdiag + lowerdiag ;
def allchunks:   A | ., transpose, diag, (map(reverse)|diag) | chunks ;

[allchunks]|max_by(add)|add

Note this challenge is basically the same as Project Euler problem 11
Try it online!

Python 2, 208 184 183 176 bytes

Saved 24 bytes by using -float("inf") to represent that the checked line reached outside the matrix instead of computing the negative sum of all matrix elements.
Saved a byte by defining R,L=range,len to shorten built-in functions and using y in R(L(A))...R(L(A[y])) instead of y,Y in e(A)...x,_ in e(Y).
Saved seven bytes by golfing float("inf") to 9e999.

lambda N,A:max(sum(A[y+q*j][x+p*j]if-1<x+p*j<L(A[y])>-1<y+q*j<L(A)else-9e999for j in R(N))for y in R(L(A))for x in R(L(A[y]))for p,q in[(1,0),(0,1),(1,1),(1,-1)]);R,L=range,len

Try it online!
Explanation
lambda N,A:                                                                                ;R,L=range,len # lambda function, golfed built-ins
           max(                                                                                )               # return the maximum line sum
                                                                                for y in R(L(A))                                                                       # loop through matrix rows
                                                                                for x in R(L(A[y]))                                                    # loop through matrix columns
                                                                                for p,q in[(1,0),(0,1),(1,1),(1,-1)]                # loop through four directions; east, south, south-east, north-east
               sum(                                                                      )                                                                                # matrix line sum
                                                                            for j in R(N)                                                                                # loop through line indices
                                  if-1<x+p*j<L(A[y])>-1<y+q*j<L(A)                                                                                # coordinates inside the matrix?
                   A[y+q*j][x+p*j]                                                                                # true; look at the matrix element
                                                                  else-9e999                                                                                # false; this line cannot be counted, max(...) will not return this line

R, 199 bytes
function(m,n,i=1,j=1){y=1:n-1
x=j-y;x[x<1]=NA
y=i-y;y[y<1]=NA
'if'(i>nrow(m)|j>ncol(m),NA,max(c(v(m[i,x]),v(m[y,j]),v(m[b(y,x)]),v(m[b(y,rev(x))]),f(m,n,i+1,j),f(m,n,i,j+1)), na.rm=T))}
v=sum
b=cbind

Try it online!
A recursive solution. For each element (i,j) of the matrix it returns the max between the sum along the row, the sum along the column, the sum along either diagonal, and the result of the function applied to (i+1,j) and (i,j+1).
Results for the test cases are shown in the TIO.

I hope I missed it, but R seems to be lacking a base function to compute the trace of a square matrix.

Haven't worked out if it would save you bytes, but you can use sum(diag(m)) for the trace

Husk, 14 bytes
▲mΣṁX⁰ṁëIT∂(∂↔

Try it online!
Thanks to the new anti∂iagonals builtin this is a quite short answer :)

JavaScript 170 bytes
still wip on the golf part
added 4 more chars because i didnt managed a case where the max is negative and N is bigger than 1

M=-1e9
G=(A,N)=>eval(`for(y in m=M,A)
for(x in R=A[y])
{for(a=b=c=d=j=0;j<N;d+=Y[x-j++])
{a+=R[X=+x+j]
b+=(Y=A[+y+j]||[])[x]
c+=Y[X]}
m=Math.max(m,a||M,b||M,c||M,d||M)}`)

console.log(G([ [3,3,7,9,3],
 [2,2,10,4,1],
 [7,7,2,5,0],
 [2,1,4,1,3]],3)==26)

 console.log(G([[-88,4,-26,14,-90],
[-48,17,-45,-70,85],
[22,-52,87,-23,22],
[-20,-68,-51,-61,41]],4)==58)

console.log(G([[9,4,14,7],[6,15,1,12],[3,10,8,13],[16,5,11,2]],4)==34)

console.log(G([[-2]],1)==-2)
console.log(G([[1,2,3,4,5]],3) ==12)

@HermanLauenstein i remove the spaces but added more coverage which added in total more chars, but thx :)

164 bytes by removing unnecessary newlines (G= is not counted)

Why did you use a||M,b||M,c||M,d||M instead of a,b,c,d?

@HermanLauenstein Math.max(NaN/undefined, 6) = NaN

Python 2, 222 218 bytes
n,a=input()
W=len(a[0]);Q=['']*W;R=range;a+=[Q]*n
for l in a:l+=Q
print max(sum(x)for y in[zip(*[(a[j][i+k],a[j+k][i],a[j+k][i+k],a[j+k][i+n+~k])for k in R(n)])for j in R(len(a)-n)for i in R(W)]for x in y if''not in x)

Try it online!

Possible 219 bytes.

Possible 218 bytes.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Ten-row bar chart
This is Hole-1 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here.

Given a list of numbers, produce a horizontal bar chart of # characters for how many numbers fit into each of ten equal-sized groups. For example, if the data ranges from 0-100, the ranges will be 0–9.9, 10–19.9, …, 90–100. (Formally, [0,10), [10,20), …, [90,100].). You may assume that there will be at least two numbers and that not all numbers will be the same.
Examples:
[1,0,0,0,0,0,0,0,0,0] gives:
#########

#

[0,1,2,3,4,5,6,7,8,9] gives:
#
#
#
#
#
#
#
#
#
#

[0,1,2,3,4,5,6,7,8,9,10] gives:
#
#
#
#
#
#
#
#
#
##

[0,1,2,3,4,5,6,7,8,9,10,11] gives:
##
#
#
#
#
#
#
#
#
##

[0,-0.5,-1,-1.5,-2,-2.5,-3,-3.5,-4,-4.5,0.5,0,-0.5,-1,-1.5,-2,-2.5,-3,-3.5,-4,1,0.5,0,-0.5,-1,-1.5,-2,-2.5,-3,-3.5,1.5,1,0.5,0,-0.5,-1,-1.5,-2,-2.5,-3,2,1.5,1,0.5,0,-0.5,-1,-1.5,-2,-2.5,2.5,2,1.5,1,0.5,0,-0.5,-1,-1.5,-2,3,2.5,2,1.5,1,0.5,0,-0.5,-1,-1.5,3.5,3,2.5,2,1.5,1,0.5,0,-0.5,-1,4,3.5,3,2.5,2,1.5,1,0.5,0,-0.5,4.5,4,3.5,3,2.5,2,1.5,1,0.5,0] gives:
###
#######
###########
###############
#########
###################
###############
###########
#######
###

[9014,9082,9077,9068,8866,8710,9049,8364,8867,9015,9064,9023,9024,8804,8805,8800,8744,8743,8714,9076,8593,8595,9075,9675,8968,8970,8711,8728,8834,8835,8745,8746,8869,8868,9073,9074,9042,9035,9033,9021,8854,9055,9017,9045,9038,9067,9066,8801,8802,9496,9488,9484,9492,9532,9472,9500,9508,9524,9516,9474,8739,9079,8900,8592,8594,9053,9109,9054,9059] gives:
#
####
#########
############
######
#########################

###########
#

[0,8,10,13,32,12,6,7,27,9,37,39,95,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,1,2,175,46,48,49,50,51,52,53,54,55,56,57,3,165,36,163,162,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,4,5,253,183,127,193,194,195,199,200,202,203,204,205,206,207,208,210,211,212,213,217,218,219,221,254,227,236,240,242,245,123,125,168,192,196,197,198,201,209,214,216,220,223,224,225,226,228,229,230,231,232,233,234,235,237,238,239,241,91,47,92,60,61,62,45,43,247,215,63,126,42,40,124,59,44,33,243,244,246,248,34,35,30,38,180,64,249,250,251,94,252,96,182,58,191,161,41,93,31,160,167] gives:
#############
######################
##########################
#########################
#########################
#
########
################
########################
##########################

So, the final group is a tiny bit larger? Like in the first example, it would be [0.9,1] (and not [0.9,1))?

@FelixPalmen Kind of. It is only larger by an infinitely small amount.

Ok, important thing to know was that it's indeed the last group that should include both endpoints, thanks

@FelixPalmen Ah, I see that that wasn't entirely clear in the OP. I'll edit it in.

Are we allowed to return a list of strings instead (list of lines)?

@Mr.Xcoder Sure.

Are we allowed to use - signs instead of #s?

@Neil No, hashes it is.

I don't understand example 1. Why 9 #s on first row. Why the last row is not empty.

@edc65 The overall range is from [0,1], and 9 of the entries in the supplied list are 0, so there are nine hashes in the first ([0,0.1)) row, and one 1 hash in the last ([0.9,1.0]) row.

@AdmBorkBork ok got it thx

I suggest adding test case [0,1,2,3,4,5,6,7,8,9,10]

@user202729 Done.

@Adám Should it be reverse instead? The top row is [0,1) containing only 0 while the bottom row is [9,10] contains both 9 and 10.

@user202729 You're right. I guess the Octave solution is wrong then!

@user202729 I should add [0,1,2,3,4,5,6,7,8,9,10,11] too.

You should have tortured Jelly by making the character be ⌸.

@Zacharý Would have been torture for everyone; afaik no 256 char char set has it.

I'm referring to languages that wouldn't be able to handle it at all.

@Zacharý I think Jelly can do Unicode.

I don't think so: https://tio.run/##y0rNyan8//9Rw5xHPTseNcz9/x8A

@Zacharý https://chat.stackexchange.com/transcript/message/40684322#40684322

R, 77 81 bytes
+4 bytes to fix some test cases
for(i in hist(x<-scan(),seq(min(x),max(x),,11),r=F)$c)cat(rep('#',i),'\n',sep='')

Try it online!
Link is to a version of the code that takes comma-separated input; this version takes space-separated.
Reads from stdin, prints to stdout.
R is a statistical programming language that does its best to give high-quality results, which is sometimes frustrating:
hist bins the inputs into a histogram with breaks as its second argument. Normally, one would expect that you could specify that the number of breaks to be 10. Indeed, this is the case:

breaks
one of:

a vector giving the breakpoints between histogram cells,
a function to compute the vector of breakpoints,
a single number giving the number of cells for the histogram,
a character string naming an algorithm to compute the number of cells (see ‘Details’),
a function to compute the number of cells.

(emphasis added).
The next sentence, however, says:

In the last three cases the number is a suggestion only; as the breakpoints will be set to pretty values, the number is limited to 1e6 (with a warning if it was larger).

So I looked at the documentation of pretty and it just doesn't work for our situation, because it picks break points thusly:

Compute a sequence of about n+1 equally spaced ‘round’ values which cover the range of the values in x. The values are chosen so that they are 1, 2 or 5 times a power of 10.

Which simply won't do.
So the seq(min(x),max(x),,11) specifies 11 equally-spaced points as the breaks, hist(x,breaks,r=F)$c gives the counts, r=F ensures that the bins are right-open intervals, and the for loop takes care of the rest.

Python 2, 96 bytes
l=input()
m=min(l)
w=max(l)-m
for i in range(10):print"#"*sum(w*i<=(x-m)*10<w*-~i+i/9for x in l)

Try it online!

Python 2, 107 95 bytes
l=input();m=min(l);s=(max(l)-m)/10.;c=0
exec'print"#"*sum(m<=v-c*s<m+s+c/9for v in l);c+=1;'*10

Try it online!

Alternative 107-byter without exec.

I rolled back your edit with my suggestion, because *.1 does not work instead of /10. for the very last test case. TBH I don't know why it does not work.

C (gcc), 241 bytes
#define P(x)for(;x--;putchar('#'));puts("");
double a[999],u,l,x;i,j,n[9];main(k){for(;scanf("%lf",&x)>0;u=u>x?u:x,l=l<x?l:x,a[i++]=x);for(;j<i;++j)for(k=0;k<9;)if(a[j]<l+(++k)*(u-l)/10){n[k-1]++;break;}for(k=0;k<9;++k){i-=n[k];P(n[k])}P(i)}

Try it online!

I think you can make k as a global, (+1byte) however it is initialized to 0, thus save 3 bytes from k=0.

Also you can switch double to float and lf to f, save another 2 bytes. (at least that works on TIO)

@user202729 for your first comment: no, this initialization is needed inside the outer loop multiple times. float might work, I didn't use it because it is not the "standard" floating-point type in C and reduces precision, so not sure this is allowed ...

234 bytes

JavaScript (ES6), 99 bytes
Edit 2 bytes save thx @JustinMariner
A function returning an array of strings
l=>l.map(v=>o[i=(v-n)/(Math.max(...l)-n)*10|0,i>9?9:i]+='#',o=Array(10).fill``,n=Math.min(...l))&&o

Less golfed
list => {
   var max = Math.max(...list),
       min = Math.min(...list),
       output = Array(10).fill(''),
       index;

   list.forEach( value => (
      index = (value - min) / (max - min) * 10 | 0,
      output [index > 9 ? 9 : index] += '#'
   ) )
   return output
}

Test

var F=
l=>l.map(v=>o[i=(v-n)/(Math.max(...l)-n)*10|0,i>9?9:i]+='#',o=Array(10).fill``,n=Math.min(...l))&&o

var test=[
[1,0,0,0,0,0,0,0,0,0],
[0,1,2,3,4,5,6,7,8,9],
[0,-0.5,-1,-1.5,-2,-2.5,-3,-3.5,-4,-4.5,0.5,0,-0.5,-1,-1.5,-2,-2.5,-3,-3.5,-4,1,0.5,0,-0.5,-1,-1.5,-2,-2.5,-3,-3.5,1.5,1,0.5,0,-0.5,-1,-1.5,-2,-2.5,-3,2,1.5,1,0.5,0,-0.5,-1,-1.5,-2,-2.5,2.5,2,1.5,1,0.5,0,-0.5,-1,-1.5,-2,3,2.5,2,1.5,1,0.5,0,-0.5,-1,-1.5,3.5,3,2.5,2,1.5,1,0.5,0,-0.5,-1,4,3.5,3,2.5,2,1.5,1,0.5,0,-0.5,4.5,4,3.5,3,2.5,2,1.5,1,0.5,0],
[0,8,10,13,32,12,6,7,27,9,37,39,95,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,1,2,175,46,48,49,50,51,52,53,54,55,56,57,3,165,36,163,162,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,4,5,253,183,127,193,194,195,199,200,202,203,204,205,206,207,208,210,211,212,213,217,218,219,221,254,227,236,240,242,245,123,125,168,192,196,197,198,201,209,214,216,220,223,224,225,226,228,229,230,231,232,233,234,235,237,238,239,241,91,47,92,60,61,62,45,43,247,215,63,126,42,40,124,59,44,33,243,244,246,248,34,35,30,38,180,64,249,250,251,94,252,96,182,58,191,161,41,93,31,160,167],
[9014,9082,9077,9068,8866,8710,9049,8364,8867,9015,9064,9023,9024,8804,8805,8800,8744,8743,8714,9076,8593,8595,9075,9675,8968,8970,8711,8728,8834,8835,8745,8746,8869,8868,9073,9074,9042,9035,9033,9021,8854,9055,9017,9045,9038,9067,9066,8801,8802,9496,9488,9484,9492,9532,9472,9500,9508,9524,9516,9474,8739,9079,8900,8592,8594,9053,9109,9054,9059]];

output=x=>O.textContent+=x+'\n\n'

test.forEach(t=>output(t+'\n'+F(t).join`\n`))

You should be able to save a couple bytes by moving the assignment for i into the array brackets followed by a comma, allowing you to remove the parentheses around the body of the map function: Try it online!

@JustinMariner right, thx

You can actually save one more byte if you get rid of i and use Math.min again, with an alias: Try it online!

Mathematica, 152 bytes
(Do[Print[""<>Table["#",Length@Select[s=#,Min@s+(t=#2-#&@@MinMax@s/10)(i-1)<=#<Min@s+t*i&]]],{i,9}];Print[""<>Table["#",Length@Select[s,Max@s-t<=#&]]])&

Try it online!

How should it work? TIO only have text output. (reply to the part "Dennis will fix it")

@user202729  thought it could be fixed. Anyway, I fixed it!

Why using the outer Table while you are not calculating anything? That output extraneous {Null,Null,Null,...,Null}. Using Do instead, both less bytes and more correct.

Fails for test case f[Range[0,10]]. / What is the N used for?

@user202729 Is this test case yours? cause for {0,1,2,3,4,5,6,7,8,9} it works fine

Yes. And Range[0,10] is {0,1,2,3,4,5,6,7,8,9,10}.

@user202729 Do you really believe that I'm not aware of this? or...

Not to offend you, but you mention Range[0,9] while I'm talking about Range[0,10] for no reason. But it actually fail for Range[0,10]: TIO.

@user202729 and you mention Range[0,10] while the original test case is [0,9] and that's why I asked.Anyway you could be more helpful since you understand my code but I think that's not the case here..

You used <= on both ends, which is correct on the last segment but not the 9 other ones.

@user202729 hey!this one helped me as much as your previous info that Range[0,n]={0,..n}. +1 for great advice. anyways the code works fine now

Jelly, 21 bytes
A monadic link returns a list of strings.
_Ṃµ÷Ṁ×⁵Ḟµ<⁵+ċÐ€⁵R¤”#ẋ

Try it online!

Although return a list of lines is permitted, the displayed result is not separated in any way. I don't know whether that is valid.

It is allowed, since that's how Jelly treats lists of string. You can add ÇŒṘ or ÇY in your footer in order to visualize the result. Also instead of full program, you can say that your submission is a monadic link, that returns rather than printing, making it automatically valid.

Charcoal, 31 bytes
≔Ｉ⪪Ｓ,θＥχ×#ΣＥθ⁼ι⌊⟦⁹⌊×χ∕⁻λ⌊θ⁻⌈θ⌊θ

Try it online! Link is to verbose version of code. Input of variable-length lists seems to a little awkward in Charcoal, so I've had to wrap the list in an array containing a string. Explanation:
   Ｓ                            Input string
  ⪪ ,                           Split on commas
 Ｉ                              Cast elements to integer
≔    θ                          Assign to variable q
      Ｅχ                        Map from 0 to 9
           Ｅθ                   Map over the list
                      ⁻λ⌊θ      Subtract the minimum from the current
                          ⁻⌈θ⌊θ Subtract the minimum from the maximum
                     ∕          Divide
                   ×χ           Multiply by 10
                  ⌊             Floor
               ⌊⟦⁹              Take minimum with 9
             ⁼ι                 Compare to outer map variable
          Σ                     Take the sum
        ×#                      Repeat # that many times
                                Implicitly print on separate lines

Pyth,  32  31 bytes
*R\#_M.++msmgk+JhSQ*dc-eSQJTQTZ

Try it here! or Verify all the test cases. (with pretty-print using j)
How this works
This is a full program that takes input from STDIN. This is for the 32-byte version. I'll update it soon.

*R\#_M.++msmgk+hSQ*dc-eSQhSQTQTZ  ~ Full program.

         m                    T   ~ Map over [0, 10) with var d.
           m                 Q    ~ Map over the input with var k.
            g                     ~ Is higher than or equal to?
             k                    ~ The current element of the input, k.
              +hSQ*dc-eSQhSQT     ~ We'll break this down into pieces:
               hSQ                  ~ The lowest element of the input list.
              +                     ~ Plus:
                  *dc-eSQhSQT       ~ We'll break this down into more pieces:
                  *                   ~ Multiplication.
                   d                  ~ The current element of [0, 10), d.
                    c       T         ~ Float division by 10 of:
                     -eSQhSQ          ~ The difference between the maximum and minium
                                        of the input list.
          s                       ~ Sum. Count the number of truthy results.
        +                      Z  ~ Append a 0.
      .+                          ~ Get the deltas.
    _M                            ~ Gets -delta for each delta in the list above.
  \#                              ~ The literal character "#".
*R                                ~ Vectorized multiplication. Optionally, you can
                                    use j to join by newlines (as the link does).
                                  ~ Output implicitly.

Fortran 2003, 263 bytes
I wrote it on GNU gfortran 5.4.0, and compiled without any additional flags.
It reads from STDIN, one value at a time, and prints to STDOUT.
Here it goes:

program h;real,allocatable::a(:);character f*9;allocate(a(0));do;read(*,*,end=8)r;a=[a,r];enddo;9 format("(",i0,"(""#""))")
8 a=(a-minval(a))+epsilon(1.);a=ceiling(10*a/maxval(a));do i=1,10;j=count(a==i);if(j==0)print*;if(j==0)cycle;write(f,9)j;
print f;enddo;end

Ungolfed explanation: (I don't know if "golfed" can be applied to fortran but either way :P)

program h
real,allocatable::a(:)       ! Create an allocatable array so we can reallocate dynamically
character f*9                ! A character array to format the output
allocate(a(0))               ! Allocate "a" empty at first
do
  read(*,*,end=8)r           ! Read from STDIN. If EOF, goes to 8, otherwise
  a=[a,r]                    ! Appends to "a"
enddo
9 format("(",i0,"(""#""))")  ! A format label
8 a=(a-minval(a))+epsilon(1.)! (8) Normalizes a (adds epsilon to avoid zero-indexing)
a=ceiling(10*a/maxval(a))    ! Normalizing and multiplying by the number of bins
do i=1,10                    ! Looping on all the bins
  j=count(a==i)              ! Counting the number of occurrences
  if(j==0)print*             ! If none, prints empty line
  if(j==0)cycle              ! And skips the rest of the loop
  write(f,9)j                ! Otherwise writes the count(j) to the print label
  print f                    ! And prints to STDOUT
enddo
end

Fun fact: I made a similar code just yesterday to test my implementation of a Weibull random number generator, so it only needed a little adaptation :)

Perl 5, 85 + 1 (-a) = 86 bytes
@F=sort{$a<=>$b}@F;map$r[($_-$F[0])/($F[-1]-$F[0])*10].='#',@F;$r[9].=pop@r;say for@r

Try it online!

Python 2, 126 121 bytes
def f(a):
 m=min(a);r=range(10);A=[sum(x>=m+i*(max(a)-m)/10.for x in a)for i in r]+[0]
 for i in r:print'#'*(A[i]-A[i+1])

Try it online!

Java (OpenJDK 8), 246 221 209 207 206 163 162 161 157 bytes
l->{String x="";double b=l[0],m=b,q,i;for(double d:l){b=dm?d:m;}for(i=(m-b)/10,q=b;q<m;q+=i,x+="\n")for(double d:l)x+=d>=q&d<q+i?"#":"";return x;}

Try it online!

Perl 5, 84 + 19 (-MList::Util=min,max) bytes
$s=-($m=min@_=@ARGV)+max@_;$a[($_-$m)*10/$s]++for@_;$a[9]+=pop@a;print"#"x$_,$/for@a

Try It Online

Perl 5, 102 bytes
$l=(@n=sort{$a<=>$b}<>)[-1]-($f=$n[0]);$m=$f+$l*$_/10,say'#'x(@n-(@n=grep$_>=$m,@n))for 1..9;say'#'x@n

Try it online.
Ungolfed:
my @n = sort { $a <=> $b } <>;
my $f = $n[0];
my $l = $n[-1] - $n[0];
for (1 .. 9) {
    my $m = $f + $l * ($_ / 10);
    my $c = scalar @n;
    @n = grep { $_ >= $m } @n;
    say('#' x ($c - scalar @n));
}
say('#' x scalar @n);

q/kdb+, 52 bytes
Solution:
{sum[t=/:bin[m+.1*(t:(!)10)*max[x]-m:min x;x]]#'"#"}

Try it online! (Note the TIO link is a 44 byte K (oK) port of this solution as there is no TIO for q/kdb+).
Examples:
q){sum[t=/:bin[m+.1*(t:(!)10)*max[x]-m:min x;x]]#'"#"}1 0 0 0 0 0 0 0 0 0f
"#########"
""
""
""
""
""
""
""
""
,"#

q){sum[t=/:bin[m+.1*(t:(!)10)*max[x]-m:min x;x]]#'"#"}9014 9082 9077 9068 8866 8710 9049 8364 8867 9015 9064 9023 9024 8804 8805 8800 8744 8743 8714 9076 8593 8595 9075 9675 8968 8970 8711 8728 8834 8835 8745 8746 8869 8868 9073 9074 9042 9035 9033 9021 8854 9055 9017 9045 9038 9067 9066 8801 8802 9496 9488 9484 9492 9532 9472 9500 9508 9524 9516 9474 8739 9079 8900 8592 8594 9053 9109 9054 9059f
,"#"
"####"
"#########"
"############"
"######"
"#########################"
""
""
"###########"
,"#"

Explanation:
Most of the code is used creating the buckets that bin buckets the input into.
{sum[t=/:bin[m+.1*(t:til 10)*max[x]-m:min x;x]]#'"#"} / ungolfed solution
{                                                   } / lambda function with implicit x as parameter
                                               #'"#"  / take (#) each-both "#", 1 2 3#'"#" => "#","##","###"
 sum[                                         ]       / sum up everything inside the brackets
         bin[                              ;x]        / binary search each x in list (first parameter)
                                    m:min x           / store minimum of list x in variable m
                             max[x]-                  / subtract from the maximum of list x
                  (t:til 10)*                         / range 0..9 vectorised multiplication against max delta of list
               .1*                                    / multiply by 0.1 (aka divide by 10)
             m+                                       / minimum of list vectorised addition against list
     t=/:                                             / match each-right against range 0..9 (buckets)

Jelly, 19 bytes
_Ṃµ÷Ṁ×⁵Ḟ«9ċÐ€⁵Ḷ¤”#ẋ

Try it online!
This is based upon my APL answer for the original problem, which I will post after that competition is over.
How? (I'm not good at explaining things)
_Ṃµ÷Ṁ×⁵Ḟ«9ċÐ€⁵Ḷ¤”#ẋ
_Ṃ                  = subtract the minimum
  µ                 = Sort of like a reverse-order compose
   ÷Ṁ               = divide by the max
     ×⁵             = Multiply by 10
       Ḟ            = Take the floor
        «9          = x => min(x,9)
          ċÐ€⁵Ḷ¤    = count occurrences of [0,...,9]
                ”#ẋ = create the list

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Output the simplified Goodstein sequence
A number is in base-b simplified Goodstein form if it is written as
b + b + ... + b + c,   0 < c ≤ b

The simplified Goodstein sequence of a number starts with writing the number in base-1 simplified Goodstein form, then replacing all 1's with 2's and subtracting 1. Rewrite the result in base-2 simplified Goodstein form, then replace all 2's with 3's and subtract 1, etc. until you reach 0.
Your program is to take a positive integer input and output/print its Goodstein sequence and terminate. Your program should handle numbers less than 100, though it may not terminate in a reasonable amount of time.
For example, given 3 as the input, your program should output (the right side is just explanation)
1 + 1 + 1                | 3 = 1 + 1 + 1
2 + 2 + 1                | Change 1's to 2's, then subtract 1. (2 + 2 + 2 - 1 = 2 + 2 + 1)
3 + 3                    | 3 + 3 + 1 - 1 = 3 + 3
4 + 3                    | 4 + 4 - 1 = 4 + 3
5 + 2                    | 5 + 3 - 1 = 5 + 2
6 + 1                    | 6 + 2 - 1 = 6 + 1
7                        | 7 + 1 - 1 = 7
7                        | 8 - 1 = 7
6                        | Numbers are now lower than the base, so just keep subtracting 1.
5                        |
4                        |
3                        |
2                        |
1                        |
0                        | End

Spacing doesn't matter.

Winning criterion:
This is code-golf. Shortest code wins.

Is it required to include the last 0?

@KSab Hm.... no, I guess not.

05AB1E, 19 bytes
Å1[D'+ý,N>D>:`Ž<)0K

Could also be rearranged as >Å1[ND>:`Ž<)0KD'+ý,
Try it online!
Explanation
Å1                    # push a list of 1's the length of the input
  [                   # start a loop
   D                  # duplicate the current list
    '+ý,              # join on "+" and print
        N>D>:         # replace <current_iteration>+1 with <current_iteration>+2
             `        # flatten the list to the stack
              Ž       # break loop if the stack is empty
               <      # decrement the top number
                )     # wrap the stack in a list
                 0K   # remove zeroes

Python 2, 77 74 bytes
-3 bytes thanks to Lynn
n=input();b=1
while n:print"+".join(n/b*[`b`]+[`n%b`][:n%b]);n+=n/b-1;b+=1

Try it online!
Easily runs up to n = 100 (though the output is too long for tio fully show).

"Spacing doesn't matter", so you're fine there.

Save a byte by reading input from STDIN: n=input() b=1 while n:…

And two more with n+=n/b-1;b+=1. 74 bytes

TIO doesn't seem to be working?

@SimplyBeautifulArt fixed

Mind I ask why creating a manual newline works while using ; doesn't?

@SimplyBeautifulArt it apparently has to do with the while loop, you can't put a while following a ;. I would guess that this is because if line is started with a while each following statement (seperated by semicolons) is considered inside its scope of the while and the behavior would be ambiguous or at least somewhat opaque

Pyth, 29 bytes
WQ=hZj\++*]Z/QZ<]J%QZJ=+Qt/QZ

Try it here!

Mathematica, 123 bytes
(s=1~Table~#;i=1;While[s!={},Print@StringRiffle[ToString/@s,"+"];s=s/.i->i+1;s=Join[Most@s,{Last@s}-1]~DeleteCases~0;i++])&

Try it online!

Python 3, 155 bytes
n=int(input());l=[1]*(n+1);i=0
while l:
    l=[t+1 if t==i else t for t in l];l[-1]-=1;l=l[:-1] if l[-1]==0 else l;print("+".join(list(map(str,l))));i+=1

This can be reformatted into
n = int(input())
l = [0]*(n+1)
i = 0
while l:
    l = [t+1 if t==i else t for t in l]
    if l[-1] == 0:
        l = l[:-1]
    print("+".join(list(map(str,l))))
    i += 1

You miss the first line of 1+1+..., and note that your program is supposed to handle any positive integer input.

corrected that -.- Should $n$ be read as input?

Yes please. Also, MathJax doesn't work on this site :P

@SimplyBeautifulArt noticed that :P corrected

Hm, you probably want to use print(" + ".join(...) to correspond with the output I require.

@SimplyBeautifulArt I put only "+" because you state spacing doesn't matter

For me, it appears you put a space in your golfed version instead of a +.

106 bytes

@ovs what is that -~ thing?

@RGS -~x has the same value as x+1, but you don't need to parenthesize it, as unary - (negation) and unary ~ (bitwise negation) do have a higher precedence than *. In your case [1]*-~n is equal to [1]*(n+1).

Javascript ES6, 121 chars
for(q=1,s=Array(+prompt()).fill(1).join`+`;s!=0;s=s.split(q).join(++q).replace(/\d+$/,x=>x-1).replace(/\+0$/,''))alert(s)

alert=s=>document.write(s+'\n')
document.write("<pre>")

for(q=1,s=Array(+prompt()).fill(1).join`+`;s!=0;s=s.split(q).join(++q).replace(/\d+$/,x=>x-1).replace(/\+0$/,''))alert(s)

Perl 5, 71 bytes
$,='+';for(@a=(++$")x<>;@a;--$a[-1]||pop@a){say@a;$_+=$_==$"for@a;$"++}

Try it online!


text:
Where can the knight be in N moves?
This is Hole-3 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here.

Given:

a number of turns (please state if no movements is 0, otherwise we'll assume it is called 1) and

a list of one or more starting positions (in any form, e.g. 0 or 1 indexed coordinates or 64 consecutive numbers/characters or A1–H8 – state which), on an 8-by-8 chessboard,

return (in any order) the list of unique positions (in the same format as the input) that knight(s) can be at after the given number of turns.

Each knight must move with every turn, but you do not have to worry about multiple knights occupying the same square.

A knight can only move to the positions marked with X relative to its current position, marked with ♞:

Examples (1-indexed coordinates)
1 move from [[1,1]]: [[2,3],[3,2]]
2 moves from [[1,1]]: [[1,1],[1,3],[1,5],[2,4],[3,1],[3,5],[4,2],[4,4],[5,1],[5,3]]
1 move from [[1,1],[5,7]]: [[2,3],[3,2],[3,6],[3,8],[4,5],[6,5],[7,6],[7,8]]
2 moves from [[1,1],[5,7]]: [[1,1],[1,3],[1,5],[1,7],[2,4],[2,6],[2,8],[3,1],[3,3],[3,5],[3,7],[4,2],[4,4],[4,6],[4,8],[5,1],[5,3],[5,5],[5,7],[6,4],[6,6],[6,8],[7,3],[7,7],[8,4],[8,6],[8,8]]
0 moves from [[3,4]]: [[3,4]]

Can chess spaces be inputted and outputted by numbering 0-63 instead of [rank, file]?

@Dave Sure, why not? Just be consistent with I/O.

I swear I read this HNQ as "Where the knight be in Ni moves"

Pun alert: the notation for knight is N.

Can we use 1-based indexing on the number of steps? E.g. [[1,1]], 2 -> [[2,3],[3,2]]

@Zgarb Sure, why not?

I like how you made [1,2] NOT be a required input value, that would save a few bytes from people's solutions.

@Zacharý In Dyalog APL 16.0 it is trivial to handle, in many languages, not so much.

Sorry, I was referring at least to some of my early submissions for the original problem.

Wolfram Language (Mathematica), 45 bytes
Because the other solution is incorrect (see Martin's comment below), so I decide to post my solution:
8~KnightTourGraph~8~AdjacencyList~#&~Nest~##&

Try it online!
Ultimate infix notation...
Takes 2 input, the first one is a list of numbers in range [1,64] describe the starting positions of the knight, the second one is the number of steps.
This solution relies on the extreme convenience of Mathematica builtin functions:

AdjacencyList may takes a list of vertices on its right side, and return a list of vertices adjacent to any of those, already removed duplicates and sorted.
KnightTourGraph is a builtin. Not surprise.
Nest takes arguments in order Nest[f, expr, n], which we can splat the ## over its right side as Nest[f, ##].
And finally, Mathematica parse a~b~c~d~e as (a~b~c)~d~e, so no square bracket is necessary. Without infix notation and flatten ##, it would be Nest[AdjacencyList[KnightTourGraph[8, 8], #] &, #, #2]&.

I don't think there is anything wrong with outgolfing an existing solution.

Does this work with multiple starting positions?

Amazing! Now I need to figure out how ti read this...

This would probably be 17 bytes in the hypothetical Mthmca golfing language.

JavaScript (ES7), 99 bytes
Input/output format: squares indices in [0 ... 63].
f=(a,n)=>n--?f([...Array(64).keys()].filter(p=>!a.every(P=>(p%8-P%8)**2^((p>>3)-(P>>3))**2^5)),n):a

Test cases
This snippet includes two helper functions to translate from and to the format provided by the OP.

f=(a,n)=>n--?f([...Array(64).keys()].filter(p=>!a.every(P=>(p%8-P%8)**2^((p>>3)-(P>>3))**2^5)),n):a

c2s = a => a.map(c => (c[0] - 1) * 8 + c[1] - 1)
s2c = a => JSON.stringify(a.map(s => [(s >> 3) + 1, s % 8 + 1]))

console.log(s2c(f(c2s([[1,1]]), 1)))
console.log(s2c(f(c2s([[1,1]]), 2)))
console.log(s2c(f(c2s([[1,1],[5,7]]), 1)))
console.log(s2c(f(c2s([[1,1],[5,7]]), 2)))
console.log(s2c(f(c2s([[3,4]]), 0)))

How?
A move from (x,y) to (X,Y) is a valid knight move if we have either:

|x-X| = 1 and |y-Y| = 2, or
|x-X| = 2 and |y-Y| = 1

By squaring instead of using absolute values, this can be expressed as:

(x-X)² = 1 and (y-Y)² = 4, or
(x-X)² = 4 and (y-Y)² = 1

Because 1 and 4 are the only perfect squares that give 5 when XOR'd together, we have a valid knight move if:
(x-X)² XOR (y-Y)² XOR 5 = 0
We apply this formula to each square p = 8y + x on the board and each knight square P = 8Y + X to deduce the new possible knight target squares, and recursively repeat this process n times.

98 bytes

@Coder Thank you! I think I'm gonna leave this old answer unchanged, but I've used your suggestion for this one.

Retina, 147 102 bytes
.$
$*
¶
 ¶
{s`((?<=N(....|.{11}|.{13})?.{7})|(?=.{8}(....|.{11}|.{13})?N))\S(?=.*	)
n
Ts`	Nn`_:N`.*¶

Try it online! Takes input as an 8x8 board of :s with the knights marked with Ns, with a digit for the number of turns on the next line (it makes no sense to have more than 9 turns, but if you insist I can support it for an extra byte). Note that the output contains additional white space. Edit: Saved 45 bytes thanks to @MartinEnder. Explanation: The first stage converts the number of turns to unary, but using tab characters, so that they don't get matched later by accident, while the second stage adds some spaces to the right of the board to stop the regexes from wrapping across the edge. The third stage replaces all Ns and :s that are a knight's move away from an N with an n while the fourth stage deletes any remaining Ns, changes the ns to Ns, and subtracts 1 from the move count. This repeats until the move count is zero.

This is most impressive. Definitely not the right tool for the job!

Octave , 69 bytes
function a=f(a,n,b=~a)for k=1:n;a=b&imdilate(a,de2bi(")0#0)"-31));end

Online Demo!
The  input/output is the configuration of the board at start/end as a binary 8*8 matrix.
Explanation:
For n steps repeat morphological dilation of the board with the following mask:
01010
10001
00100
10001
01010

Jelly, 29 bytes
+þ1,2Œ!×þ1,-p`¤¤Ẏ¤Ẏ⁼%8$$ÐfQµ¡

Try it online!
0-indexed coordinates. Almost certain this is suboptimal.
-1 byte thanks to user202729
Explanation
+þ1,2Œ!×þ1,-p`¤¤Ẏ¤Ẏ⁼%8$$ÐfQµ¡  Main Link
+þ                             Addition Table (all pairs using + as combining function) with
  1,2Œ!×þ1,-p`¤¤Ẏ¤             All knight moves:
  1,2                          [1, 2]
     Œ!                        All permutations ([1, 2], [2, 1])
       ×þ                      Product Table (all pairs using × as combining function) with
         1,-p`¤                [1, 1], [1, -1], [-1, 1], [-1, -1]
         1,-                   [1, -1]
            p`                 Cartestian Product with itself
               ¤               All knight moves (in a nested array) as a nilad
                Ẏ¤             Tighten (flatten once); all knight moves in a (semi-)flat array
                        Ðf     Keep elements where
                   ⁼%8$$       The element equals itself modulo 8 (discard all elements out of the range)
                          Q    Remove Duplicates
                           µ   Start new monadic chain (essentially, terminates previous chain)
                            ¡  Repeat n times; n is implicitly the second input (right argument)

0-indexed Jelly?

@Adám Makes the filtering easier :P

I expect Jelly to be able to do this in under 15 bytes, due to the current record holder in APL does it in 24 characters.

When you have >= 3 $, it is likely that you can move it to the previous link and refer back with Ç.

@user202729 Oh yeah true, thanks.

@Adám Yeah I'm still somewhat less experienced in Jelly than I'd like to be so surely someone can outgolf me by a ton :P

When have you started learning Jelly? I'm almost certain much earlier than mine because you get your name on Jelly Hypertraining already when I started learning.

@user202729 I forget the exact time but I started learning Jelly at the beginning of HyperTraining (I was the first student! \o/ :P)

Is there any way to avoid the second $$$? Can µ be used? I see there are no "terminate monad chain" symbol, only "start other chain" so I suppose no...

@user202729 I tried; unfortunately not.

@Adám, unless you know that it's not a dfn, that might be incorrect. Because IIRC the braces around a dfn solution don't count towards the bytecount in that competition. (This whole comment refers to "the current record holder in APL does it in 24 characters").

Also, can you add an explanation for the plebs who don't understand Jelly that well?

@Zacharý done :)

05AB1E, 27 25 bytes
Thanks to Emigna for saving 2 bytes!
Uses 1-indexed coordinates.
Code:
F•eĆ•SÍü‚Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!
Explanation:
F                          # Do the following <input_1> times..
 •eĆ•SÍ                    #   Push [-1, -2, 1, 2, -1]
       ü‚                  #   Pairwise pairing: [[-1, -2], [-2, 1], [1, 2], [2, -1]]
         D                 #   Duplicate the array
          í                #   Reverse each element
           «               #   Concatenate to the previous array

This gives us the following array:
[[-1, -2], [-2, 1], [1, 2], [2, -1], [-2, -1], [1, -2], [2, 1], [-1, 2]]

Which are the deltas of the moves of the knight.
            δ+             #   Addition vectorized on both sides
              €`           #   Flatten each element
                Ù          #   Uniquify
                 ʒ         #   Keep elements which..
                  {`9‹     #     Has a maximum element smaller than 9
                      *0›  #     And a minimum element larger than 0

You can use •eĆ•SÍü‚ instead of Ƶ‡4в2ô<D(« to save 2 bytes.

@Emigna Ahh, that's clever, thanks!

Java (OpenJDK 8), 124 bytes
(m,p)->{for(;m-->0;)for(long a=p,i=p=0,j;i<64;i++)for(j=64;j-->0;)p|=(p=i%8-j%8)*p+(p=i/8-j/8)*p==5?(a>>i&1)<<j:0;return p;}

Try it online!
Input / Output format
The input/output is represented as bits in a long (64 bits): set bits mean a horse is present, unset bits mean no horse. Example:
// [[0, 0]]
0b00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000001L

Explanations
(m, p) -> {                          // Lambda. No currying because m and p are modified
 for(;m-->0;)                        // For each move
  for(long a=p,i=p=0,j;i<64;i++)     // Declare variables, move p to a, create a new p and loop on bits of a.
   for(j=64;j-->0;)                  // Loop on bits of p.
    p |=                             // Assign to p a value.
     (p=i%8-j%8)*p+(p=i/8-j/8)*p==5  // If i -> j is a valid horse move, see Arnauld's JavaScript answer for full explanations
      ? (a>>i&1)<<j                  // Assign the presence of the horse (i-th bit of a) to the resulting board (j-th bit of p).
      : 0;                           // Else it's not a valid horse move
 return p;
}

Credits

19 bytes saved thanks to Nevay!
Reused the (X-x)²+(Y-y)²==5 trick from Arnauld's JavaScript answer
1 more byte saved thanks to Nevay in the new algorithm!
7 more bytes saved thanks to Nevay again by switching from int[] to 64-bits long.

169 bytes: (m,p)->{for(;m-->0;){int i=64,a[]=p,x,y,u[]={1,3,5,9,15,19,21,23};for(p=new int[i];i-->0;)for(int z:u)if((((x=i/8+z/5-2)|(y=i%8+z%5-2))&-8)==0)p[x*8+y]|=a[i];}return p;}

-1 byte: (m,p)->{for(int i,j,a[],x;m-->0;)for(a=p,p=new int[i=64];i-->0;)for(j=64;j-->0;)p[j]|=(x=i%8-j%8)*x+(x=i/8-j/8)*x==5?a[i]:0;return p;}

Thank you @Nevay! Adding code to remove parenthesis/blocks is always nice! ;-)

-7 bytes by replacing int[] with long: (m,p)->{for(long i,j,a;m-->0;)for(a=p,p=i=0;i<64;i++)for(j=64;j-->0;)p|=(p=i%8-j%8)*p+(p=i/8-j/8)*p==5?(a>>i&1)<<j:0;return p;}

Cheers, I didn't even think about doing such! Nice job, @Nevay ;-)

Jelly, 29 28 bytes
8Rp`
“¦Ʋƈ2’D_2ṡ2+€µẎ
ÇƓ¡f1£Q

Try it online!
Number of turns is through STDIN, and squares is an argument.
This ties @HyperNeutrino's Jelly solution, but with a different approach.
Now beating @HyperNeutrino by 1 whole byte!
Any suggestions to knock off some bytes are wanted!
Link 1 (The chessboard)
8Rp`
8R   = The list [1,2,3,4,5,6,7,8]
  p` = cartesian multiplied with itself (this results in the chessboard)

Link 2 (Move generation)
“¦Ʋƈ2’D_2ṡ2+€µẎ
“¦Ʋƈ2’          = the number 103414301
      D         = converted into a list of digits
       _2       = subtract two from each element
         ṡ2     = overlapping pairs
           +€   = add to the list of squares
             µ  = Make sure the next part isn't treated as a right argument
              Ẏ = Tighten the list (Reducing the depth by one)

Link 3 (square checking)
ÇƓ¡f1£Q
ÇƓ¡     = Repeat link #2 the requested amount of times
   f1£  = Remove everything not a member of link #1 (not on the chess board)
      Q = Make sure squares don't appear more than once

Husk, 18 bytes
u!¡ṁö`fΠR2ḣ8=5ṁ□z-

Uses 1-based indexing of squares and steps.
Try it online!
Explanation
u!¡ṁö`fΠR2ḣ8=5ṁ□z-  Implicit inputs, say P=[[1,1],[5,7]] and n=2
  ¡                 Iterate on P:
   ṁö               Map the following function, then concatenate:
                     Argument is a pair, say p=[5,7].
          ḣ8         The range [1,2,..,8]
       ΠR2           Repeat twice, take cartesian product: [[1,1],[1,2],..,[8,8]]
     `f              Filter with this predicate:
                      Argument is a pair, say q=[3,8].
                z-    Zip p and q with difference: [-2,1]
              ṁ□      Sum of squares: 5
            =5        Is it 5? Yes, so [3,8] is kept.
 !                  Take n'th step of the iteration.
u                   Remove duplicates, implicitly print.

Python 3, 105 bytes
p=lambda g,i:i and list(set(p([x+y for x in g for y in[6,10,15,17,-6,-10,-15,-17]if 0<=x+y<64],i-1)))or g

Have to use a named lambda for the recursion. Not sure if that's disqualifying. Pass in starting positions as 0-indexed square number list. 0 counts as no moves.

R, 145 183 134 bytes
This is the result of Giuseppe's excellent golfing of my initial not-too-golfy algo (see comment below)
function(x,n){x=x%/%8*24+x%%8
t=c(49,47,26,22)
t=c(t,-t)
for(i in 1:n)x=intersect(v<-outer(1:8,0:7*24,"+"),outer(x,t,"+"))
match(x,v)}

Try it online!
Input and output are 1...64 based.
Takes a vector of position using the 1...64 notation. Maps it to a 1:576 notation, that is a super-board made of nine boards.
In this notation, at each iteration, each knight should be able to move by +/- 22,26,47,49
Return future positions back in the 1...64 notation, excluding those that fall off the central board. The TIO example displays the result using an 8x8 matrix.

This seems to fail on the first test case (it returns 4 coordinates instead of 2).

Thank you for pointing it out Zgarb, I think I fixed the issue now

154 bytes

or 148 bytes if you take it in [0...63] notation instead.

134 bytes, [1..64] for input and output. +1, though, this is an excellent answer.

Nice! I just learned 'outer' :)

Ah, yes, outer is handy! Make sure you read up on tips for golfing in R, and feel free to ping me in chat. I think there's still some savings to be made in this answer, and I look forward to more of your submissions here. :)


text:
Invert a Quine!
We all know what a quine is.  An inverted quine is a non-empty program that prints the inverse of its source code without reading its source code, and consists solely of printable-ASCII characters (space through ~).
Here, “inverse of the source code” means the following: the output of your program must contain each printable ASCII character (m − c) times, where c is the number of times said character occurs in your code, and m is the maximum number of times any character is repeated in your code.
(In other words: your code + your output = permutation of m times all of printable-ASCII.)
For example, if your program is 12345, then m = 1, and you should output any permutation of this string:
 !"#$%&'()*+,-./06789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

If your program is AAB, then m = 2, and you should output any permutation of:
  !!""##$$%%&&''(())**++,,--..//00112233445566778899::;;<<==>>??@@BCCDDEEFFGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ[[\\]]^^__``aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~

Note how there are two missing As, and one missing B.
Although a program that contains all the printable ASCII characters and outputs nothing is a valid inverse quine (satisfying m = 1), such an answer would not be very competitive, given its length.
You are to write a program that is an inverted quine, as described in the above paragraph.  As this is code-golf, the shortest program in bytes will win. Good luck!

Sandbox

@HyperNeutrino This contains several additional conditions that would invalidate quite a few submissions, including the winning one.  In my opinion, it isn't a dupe.

Space, tab and newline?

You should highlight the duplicated for every repeated character in the source code it makes all the difference in the challenge

Could you give an example of the inverse where multiple characters are repeated (and multiple times)? Say, 11234512345?

If I understand the challenge correctly, it indeed isn't a dupe. But you should clarify the challenge and add more examples. I think I understand what you mean, but I'm not entirely sure. Could you check my comments on the Java answer and QBIC answer to see if I understand it?

How is this a duplicate? Related, yes. Duplicate, no! It's way more difficult in languages where you have to have duplicate characters. Note that you can't just duplicate a string either, since the number of characters you must remove from each string is varying.

@StewieGriffin I would VTC this as "unclear" rather than a "dupe" because (nearly) every answer has a comment trying to figure out what duplicated for every repeated character in the source code means or if the submission is valid for that criterion, because the OP hasn't addressed quite a few of the questions here.

I've voted to close as unclear too.

@StewieGriffin, no, spaces, tabs and newlines are not technically included in printable-ascii, and as such, are banned.

You should specify what happens if the code is aabb, and aaabbc.Is the following correct, assuming the printable characters only contain abcd? The output from aabb should be cdcd, and the output for aaabbc should be cdbcd. Can you confirm or refute this, and if so, provide the correct answer?

My take on it: your output must contain each printable ASCII character m-x times, where x is the frequency of that character in your code, and m is the maximum frequency of any character in your source code.

@Lynn exactly.  I'm having trouble putting that into words, but if you want to edit your explanation in to the question, that'd be great.

@Gryphon I’ve edited your question to explain the question as it’s clear to me, and voted to reopen — could you check if I got it right?

Brain-Flak, 221 207 bytes
Includes +1 for -A
(((((((()()()()){}){}()){}){})()){}{}){({}[()]<((((((()()()()){}){}){})<>[()()()])[()])((((()()()){})){}{})<>((()()()()){}){({}[()]<(({})())>)}{}({}()())<>{{({}<>[()]<(({})())><>)}{}<>(({}())()())<>}<>>)}{}

Try it online!
# Push 206 (the number of times to duplicate the output)
(((((((()()()()){}){}()){}){})()){}{})

# For 0 to 206
{({}[()]<

    # Push 32 on this stack and 18, 28 and 29 to the other
    # 18, 28 and 29 are the distances between the sets of braces
    ((((((()()()()){}){}){})<>[()()()])[()])((((()()()){})){}{})<>

    # For 0 to 8
    ((()()()()){}){({}[()]<

        # Push TOS, TOS + 1
        (({})())

    # end For 0 to 8
    >)}{}

    # Push TOS + 2
    # skips '(' and ')'
    ({}()())

    # For each value on the off stack (18, 28, 28)
    <>{

        # For 0 to that number
        {({}<>[()]<

            # Push TOS, TOS + 1
            (({})())

        # End for 0 to that number
        ><>)}{}

        # Push TOS + 1, TOS + 3 (skips this set of braces)
        <>(({}())()())<>

    # End for each value on the off stack (18, 28, 28)
    }<>

 # End for 0 to 206
 >)}{}

I think you should only remove [ five times, not all times. Note that 2 is only removed once in the example. The challenge is a bit confusing though.

Interesting how this is drastically shorter than the standard quine. +1 :)

This is really lame, and significantly less interesting than your answer, but technically, `!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~` would get a better score :/

CJam, 17 bytes
{s95c+'|,32>\-}_~

Try it online!
Prints
 !"#$%&()*./014678:;<=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^`abdefghijklmnopqrtuvwxyz

Explanation
The goal was to modify the standard quine
{"_~"}_~

such that no character is repeated in the program. The reason for this is that CJam has a set different operator which we can use to remove characters from the printable ASCII range, but it doesn't take number of occurrences into account. Implementing that by hand would probably be longer, so I needed to make sure that every character appears only once and we don't have to worry about occurrences.
{      e# Quine framework. Executes the block while leaving another copy of the
       e# block on the stack.
  s    e#   Stringify the block, giving us "{s95c+'|,32>\-}".
  95c  e#   Convert 95 to a character, which gives us '_' without repeating
       e#   it in the source code.
  +    e#   Append it to the string. We don't need to worry about '~', we'll just
       e#   leave it out of the printable ASCII range to begin with.
  '|,  e#   Get a character range from the null byte up to '{'. This omits "|}~",
       e#   but those are in the program anyway, it doesn't matter.
  32>  e#   Discard the unprintable characters.
  \-   e#   Subtract the source string from the printable ASCII range.
}_~

Python 3, 83 bytes
print(~2/8,6>9)#!"$%&'*+14:;<=?@ABCDEGHIJKLMNOPQRSTUVWXYZ[\]^_`bcdfghjkmoquvwxyz{|}

Try it online!
Prints -0.375 False.

05AB1E, 95 61 60 bytes (not 58 b/c I dislike that one)
A?9L<J, !"'#$%&()*+-./:;=>@BCDEFGHIKMNOPQRSTUVWXYZ[\]^_`{|}~

Try it online!
Old answer invalidated by "only-ASCII characters", a lot of commands aren't valid here.
It prints abcdefghijklmnopqrstuvwxyz012345678 one time as there are no duplicated characters.

Version with BCDEFGHIKMNOPQRSTUVWXYZ removed:
Work in progress... I think ~60 bytes is as low as you get without non-ASCII characters in 05AB1E..
05AB1E, 58 bytes
T5+FA'uK?Au"ADLJFKST"SK?9L<5KJ?} !#$%&()*>-./:;=@[]^_`{|~\

Try it online!
Prints the output x12 due to the repeated characters:
['""', '55', '???', 'AAA', 'FF', 'JJ', 'KKKK', 'LL', 'SS', 'TT', 'uu']

It also doesn't terminate quite correctly, working on that now...

Invalid old answers (due to non-ASCII characters) have been removed, see edit history.

"An inverted quine is a non-empty program that prints the inverse of its source code without reading its source code, and consists solely of printable-ascii characters." I was working on an 05AB1E answer, too, until I noticed this.

@KSmarts fixed at a cost of 76 bytes.

Typically, in a code-golf challenge, one would expect 05AB1E to do a little better than, "beats Java".

@KSmarts shrug if you don't let esolangs easily compete by definition, you deserve a sarcastic esolang answer :P.

Java 8, 106 99 190 bytes
class i {/*{}!"#$%&'()+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bdefghjkmnopqrtuvwxyz|~!"#$%&'()+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`claibdefghjkmnopqrtuvwxyz|~*/}

You can probably golf it by removing the space in i { because you already have a space

I believe that every character must occur the same number of times for this to be valid

I'm not sure if I understand the challenge completely, but isn't just class i{/*!"#$%&'()+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bdefghjkmnopqrtuvwxyz|~*/} enough? It contains all printable-ASCII in it's source code, and outputs nothing. The part "duplicated for every repeated character in the source code" applies to the output, so even though s is duplicated in class and * and / are duplicated due to /* */, outputting four times nothing is still nothing.

Also, if I'm indeed correct, you can also golf it to: interface Z{}//!"#$%&'()*+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY[\]^_`bdghjklmopqsuvwxyz|~ (97 bytes)

Javascript (ES6), 103 101 bytes
_=>` !"#$%&'()*+,-.0123456789:;<?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^abcdefghijklmnopqrstuvwxyz{|}~`//_=>\\

Old solution (103 bytes using alert)
alert;;alert`\ \!"#$%&'()*+,-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_bcdfghijkmnopqsuvwxyz{|}~`

Old (invalid) solution (96 bytes)
alert()// !"#$%&'*+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bcdfghijkmnopqsuvwxyz{|}~

You have two //, which means you must output the printable characters, with one / removed. (I think)

@StewieGriffin Fixed


text:
Triangular Numbers
(no, not those ones)
The Challenge
You'll be given two inputs. The first is a positive integer n > 0, which is used to output an n x n right triangle of the numbers 1, 2, 3, ... n. This triangle starts in a corner and increases horizontally and vertically by one and diagonally by two. See examples below for clarification. Keep one space between columns and keep all numbers right-aligned in their particular columns. (This is ascii-art after all).
The second input, x, is one of four distinct single ASCII characters of your choice that determines the triangle's starting corner (and hence orientation). For example, you could use 1,2,3,4 or a,b,c,d or #,*,!,), etc. Please specify in your answer how the orientation works.
For clarification in this challenge, I will use 1,2,3,4 which will correspond to 1 for the upper-left, 2 for the upper-right, and so on clockwise.
The Examples
For example, for n = 5, x = 1 output the following:
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5

For input n = 11, x = 1 output the following (note the extra spaces so the single digits are right-aligned):
 1  2  3  4  5  6  7  8  9 10 11
 2  3  4  5  6  7  8  9 10 11
 3  4  5  6  7  8  9 10 11
 4  5  6  7  8  9 10 11
 5  6  7  8  9 10 11
 6  7  8  9 10 11
 7  8  9 10 11
 8  9 10 11
 9 10 11
10 11
11

With input n=6 and x=2 output:
6 5 4 3 2 1
  6 5 4 3 2
    6 5 4 3
      6 5 4
        6 5
          6

With input n = 3 and x = 4, output:
3
2 3
1 2 3

With input n = 1 and any x, output:
1

The Rules

Leading/trailing newlines or other whitespace are optional, provided that the numbers line up appropriately. (For example, trailing whitespace to make a square output is acceptable).
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Output can be to the console, saved as an image, returned as a list of strings, etc. Any convenient and allowed format.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

This question is just this + this.  I don't know yet but I feel like this is a dupe of one of them.

@WheatWizard I don't think answers from either of those challenges can be trivially modified to be competitive here.

To be honest I know a lot of people say thats what makes a duplicate, but as far as I can tell its not a rule.  To me a duplicate is a question that offers nothing in terms of challenge that's not provided by existing questions.

@WheatWizard Meta consensus.

I've read that answer.  Its a recommendation in a more specific context not a universal ruling.

Jelly, 13 bytes
Rṫ`z⁶ṚH}¡U⁹¡G

Try it online!
Left argument: n
Right argument: x (0 = top-left, 1 = top-right, 2 = bottom-left, 3 = bottom-right)

APL (Dyalog), 29 bytes
{' '@(=∘0)⌽∘⍉⍣⍺⊢↑⌽(⍳+⍵-⊢)¨⍳⍵}

Try it online!
How?
¨⍳⍵ - for each i in range of n
(⍳+⍵-⊢) - produce range of i with vectorized addition of n - i
↑⌽ - reverse and flatten
⌽∘⍉ - rotate right
⍣⍺⊢ - x times
' '@(=∘0) - remove zeros

MATL, 18 bytes
:&YhiX!VZ{' 0'2:YX

First input is n.  Second input is x, which can be:

0: top left
1: bottom left
2: bottom right
3: top right

(Or it can be any other integer, which is interpreted modulo 4).
Try it at MATL Online!

JavaScript 130 128 154 142 138 135 133 bytes
*fixed padding issues

A=(n,x)=>(j=>{for(;n--;s=x<3?S+`
`+s:s+S+`
`)
for(S=O,i=j;i;S=i-->n^~-x%3?X+S:S+X)
X=(i>n?i+O:O).padStart(j.length+1)})(n+=s=O="")||s

console.log(A(6,1))
console.log(A(6,2))
console.log(A(6,3))
console.log(A(6,4))

console.log(A(12,1))
console.log(A(12,2))
console.log(A(12,3))
console.log(A(12,4))

/* 154 solution
A=(n,x)=>{s=""
for(j=n;n--;s=x<3?S+`
`+s:s+S+`
`)
for(S="",i=j;i;S=i-->n?~-x%3?S+X:X+S:~-x%3?X+S:S+X)
X=(i>n?i+"":"").padStart((j+"").length+1)
return s
}

142 solution
A=(n,x)=>{s=""
for(j=n;n--;s=x<3?S+`
`+s:s+S+`
`)
for(S="",i=j;i;S=i-->n ^ ~-x%3?X+S:S+X)
X=(i>n?i+"":"").padStart((j+"").length+1)
return s
}

138 solution
A=(n,x)=>{s=""
for(j=n+" ";n--;s=x<3?S+`
`+s:s+S+`
`)
for(S="",i=+j;i;S=i-->n^~-x%3?X+S:S+X)
X=(i>n?i+"":"").padStart(j.length)
return s
}

135 solution
A=(n,x)=>{for(j=n+=s=O="";n--;s=x<3?S+`
`+s:s+S+`
`)
for(S=O,i=j;i;S=i-->n^~-x%3?X+S:S+X)
X=(i>n?i+O:O).padStart(j.length+1)
return s
}
*/

@AdmBorkBork i think i fixed it now

Python 2, 124 120 bytes
n,x=input()
r=range(n)
for l in zip(*[(r+[n]+['']*i)[-n:]for i in r][::1-x%4/2*2])[::1-x/3*2]:print' %%%ds'%len(`n`)*n%l

Try it online! or Try all test cases
(r+[n]+['']*i)[-n:] will add some empty strings to the number list, and chop to the right size, zip with [::1-x%4/2*2] and [::1-x/3*2] will make the rotation, and %%%ds'%len(`n`)*n will generate a string for fomating (like ' %3s %3s %3s'...) to be used on each numbers+empty string list

Mathematica, 89 bytes
(R=Reverse;Grid[{#&,R/@#&,R[R/@#]&,R@#&}[[#2]]@PadRight@Array[Range[#,s]&,s=#]/. 0->""])&

here is another solution that works in TIO
Mathematica, 122 bytes
(R=Reverse;StringRiffle[""<>ToString/@#&/@({#&,R/@#&,R[R/@#]&,R@#&}[[#2]]@PadRight@Array[#~Range~s&,s=#]/. 0->" "),"\n"])&

Try it online!

Charcoal, 39 bytes
Ｎτ≔ＥτＥτ◧×‹⁺ιλτＩ⊕⁺ιλＬθσＦＮ≔⮌ＥσＥσ§μλσＥσ⪫ι

Try it online! Note: Trailing space. Link is to verbose version of code. Second value is number of anticlockwise rotations so 0 is upper left, 1 lower left, 2 lower right, 3 upper right. Explanation:
Ｎτ                                      Assign the first input as an integer
   ＥτＥτ                                 Map in two dimensions
               ⊕⁺ιλ                     Sum of zero-indexed coordinates plus 1
              Ｉ                         Cast to string
         ‹⁺ιλτ                          Is this the upper left triangle?
        ×                               Repeat the string once if so
       ◧           Ｌθ                   Pad to length of first input
  ≔                  σ                  Assign to variable
                          ＥσＥσ§μλ       Transpose the array
                         ⮌              Reflect the array, giving a rotation
                        ≔        σ      Reassign to variable
                       Ｎ                Second input as an integer
                      Ｆ                 Repeat that many times
                                  Ｅσ    Map over array
                                    ⪫ι  Join with spaces and implicitly print

Javascript (ES6), 241 222 214 bytes

let f =

    (n,x)=>(L=x=>(''+x).length,M=b=>x&b?(c,i,a)=>a[n-1-i]:c=>c,Array(n).fill(b=' ').map((c,i)=>b.repeat(L(n)-L(++i))+i).map((c,i,a)=>a.map((v,j)=>j>i?b.repeat(L(n)):v)).map(M(1)).map(c=>c.map(M(2))).map(c=>c.join(b)))

function printTriangle() {  // display array of strings returned by f
    o.innerText = f(
       +Length.value, // number
       Rotate.value[0] // ASCII char
    ).join('\n');
}
Length: <input type="text" value="11" id="Length">

Rotate: <input type="text" value="0" id="Rotate"> 0,1,2,3

<button type="button" onclick="printTriangle()">
  OK
</button>

Less Golfed
(n,x)=>(
    L= x=> (''+x).length,                // strlen(x)
    M= b=> x&b ? (c,i,a)=>a[n-1-i] : c=>c, // reverse or identity map
    Array(n).fill(b=' ')
   .map((c,i)=>b.repeat(L(n)-L(++i))+i)  // a complete line of numbers
   .map((c,i,a)=>a.map((v,j)=>j>i?b.repeat(L(n)):v)) // to 2-d array
                                         // with spaces for blank numbers
   .map(M(1))                            // flip vertically?
   .map(c=>c.map(M(2)))                  // flip horizontally?
   .map(c=>c.join(b))                    // convert lines to strings
)

Note on orientation.
The second parameter is a character from {'0', '1', '2', '3'} and automatically type converted to a number by the & operator. If bit 0 (lsb) of the number is set, lines are flipped vertically. If bit 1 (nlsb) is set, columns are flipped horizontally. Other decimal digit characters can be used with predictable results.
Trailing Spaces
Blank entries in the output string have been replaced with spaces, which means lines have trailing spaces in orientations '0' and '1'.

Lua, 250 bytes
function f(w,m)d=""for y=1,w do for x=1,w do d=string.format("%s%"..tostring(w):len().."s ",d,m<2 and(y+x-1<=w and x+y-1 or"")or(m<3 and(x>=y and w-x+y or"")or(m<4 and(y+x-1>=w and w+w-x-y+1 or"")or(y>=x and w-y+x or""))))end;d=d.."\n"end;print(d)end

Takes parameters [w]idth and [m]ode using 1,2,3,4 for modes as described in the example.

05AB1E (61 bytes)
F¹N-LN+¹N-LN+Rõ¸N∍s«N>LN¹<--N>LN¹<--Rõ¸¹<N-∍s«)²èvy¹gyg-ú}ðý,

Try it online

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/