# 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 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. Oct 16 '17 at 19:04
• @ElPedro The reason behind the many downvotes is a known unknown Oct 16 '17 at 21:18
• May we return a matrix or a list of strings?
Oct 17 '17 at 7:57
• @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. Oct 17 '17 at 12:21
• Are the trailing spaces intentional? Dec 25 '17 at 15:16

# 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 Oct 16 '17 at 15:13 • you're totally right, a shame that it dumbs the solution so much down though. Oct 16 '17 at 15:15 • Is the space after the comma needed? Oct 16 '17 at 15:17 • Using split..join instead of replace saves one byte. – user72349 Oct 16 '17 at 15:41 • I meant by removing the 0s and using .replace(/ |s/g,'known$&') (which now only saves 3 bytes).
– Neil
Oct 17 '17 at 8:56

# Bash, 605754 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 Oct 18 '17 at 11:15 • @L3viathan 54 even, as you won't need the -e after echo! :) Oct 18 '17 at 11:16 • a=known;b=${a}sb=${a=known} Oct 18 '17 at 13:05 • @manatwork you meant b=${a=known}s, but I got it – thanks! Oct 18 '17 at 13:10

# 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


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! # 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! # 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  # 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". # 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 Oct 16 '17 at 22:22 • 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 Oct 16 '17 at 22:28 • @Conor O'Brien oh, fair enough Oct 16 '17 at 22:28 # ///, 35 bytes /2/un1//1/known/1 1s 1 2s 2 1s 2 2s  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'))  # 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. Sep 10 '18 at 14:54 • @StephenLeppik, not any more Sep 10 '18 at 15:01 • Ah, haven't been paying enough attention to Meta then :/ sorry about that. Sep 10 '18 at 15:06 # 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. Sep 13 '18 at 17:38 • whoops, another byte to save: _c"unknown known"d=>c"known unknown"d Sep 14 '18 at 22:34 # 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  ## Python 3, 69 bytes k=['known','unknown'] for i in range(4):print(k[i//2]+' '+k[i%2]+'s')  • Welcome to PPCG! Nov 16 '18 at 16:34 • thanks @AdmBorkBork ! Nov 16 '18 at 16:36 # 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. # MathGolf, 2319 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? – Jo King Nov 19 '18 at 7:58 • @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. – maxb Nov 19 '18 at 8:52 • Ah, I had assumed that it added a newline character to the stack – Jo King Nov 19 '18 at 9:30 • @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. – maxb Nov 19 '18 at 9:44 # 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 Jul 29 '19 at 19:34

# Vyxalj, 15 bytes, (@lyxal)

»² ¢λ⌈:ẊvṄ\s+


Try it Online!

# Vyxalj, 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 Jun 7 at 11:45
• @lyxal thanks!! Jun 7 at 12:11