57
votes
N-dimensional N^N array filled with N
Python, 32 bytes
lambda n:eval('['*n+'n'+']*n'*n)
Try it online!
Makes a string like "[[[n]*n]*n]*n" with ...
50
votes
No strings (or numbers) attached
Funciton, 1222 bytes
Apart from numeric literals, there are two ways I can produce a value (any value at all) in Funciton: stdin and lambda expressions. Stdin is a single box while a full lambda ...
34
votes
26
votes
No strings (or numbers) attached
JavaScript, 144 141 140 138 132 125 123 bytes
With help from @edc65, @Sjoerd Job Postmus, @DocMax, @usandfriends, @Charlie Wynn and @Mwr247!
...
22
votes
Fill the rows, columns, and diagonals of an NxN grid with 1 through N
Funciton, non-competitive
UPDATE! Massive performance improvement! n = 7 now completes in under 10 minutes! See explanation at bottom!
This was good fun to write. This is a brute-force solver for ...
21
votes
Accepted
No strings (or numbers) attached
Hexagony, 13 bytes
1
2
3
4
5
6
7
8
9
10
42
Try it online!
In Hexagony, 0 through 9 are functions that multiply the current ...
16
votes
No strings (or numbers) attached
Mouse-2002, 27 26 17 14 bytes
The first snippets push 0-10, and ZR+ pushes 25 then 17 and <...
16
votes
16
votes
15
votes
15
votes
All the k-mers/n-grams
Jelly, 1 byte
ṡ
Jelly has a single byte dyadic atom for this very operation
Try it online! (the footer splits the resulting list with newlines, to avoid a ...
13
votes
13
votes
N-dimensional N^N array filled with N
Mathematica, 22 20 bytes
(t=Table)@@t[#,#+1]&
(* or *)
Table@@Table[#,#+1]&
12
votes
No strings (or numbers) attached
Perl 5, 86 75 71 66 bytes
All ^Fs are literal control characters (0x06 in ASCII), and hence a single byte.
...
12
votes
No strings (or numbers) attached
Brainfuck, 70 bytes
+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
--[>+<++++++]>-
Each line must be run individually.
The first 10 ...
12
votes
No strings (or numbers) attached
Darkness, 339 303 bytes
This is where Darkness really shines. Get it? :~)!
Without printing (replaced the space with \s in the first line since it won't show ...
10
votes
10
votes
No strings (or numbers) attached
MATL, 30 bytes
O
l
H
I
K
Kl+
HI*
KYq
HK*
IH^
K:s
IH^:sI-
H, I, and ...
10
votes
N-dimensional N^N array filled with N
JavaScript (ES6), 44 40 bytes
f=(n,k=i=n)=>i--?f(n,Array(n).fill(k)):k
Demo
...
10
votes
N-dimensional N^N array filled with N
Octave, 35 33 25 23 20 bytes
@(N)ones(N+!(1:N))*N
Try it online!
@(N)ones(N*ones(1,N))*N
@(N)repmat(N,N*ones(1,N))
Thanks to @...
10
votes
N-dimensional N^N array filled with N
R, 26
This is the obvious answer but perhaps there is something cleverer?
n=scan();array(n,rep(n,n))
10
votes
Typo resistant pin codes
Python 2, 1000 unique pin codes, 44 bytes
i=0;exec'print i+int(`i`,11)%10;i+=10;'*1000
Try it online!
I suspect 1000 pin codes is optimal. You can check the ...
9
votes
9
votes
No strings (or numbers) attached
PHP, 157 145 91 bytes
First time posting on Code Golf, figured I'd give it a shot. I'll get better eventually :P If you see any obvious (to you) spots where I could save characters, let me know.
...
9
votes
No strings (or numbers) attached
PowerShell, 147 bytes
These use + to implicitly cast things to integers. The later numbers use Enums from the .Net Framework unerpinnings of PowerShell which ...
9
votes
No strings (or numbers) attached
Python 2, 191 159 158 157 156 149 146 bytes
My first submission ever, I hope I got everything right !
Based on the time I spent on this, I guess there's surely a better one for a few of them.
...
9
votes
N-dimensional N^N array filled with N
05AB1E (legacy), 6 5 bytes
-1 thanks to Kevin Cruijssen
F¹.D)
Try it online!
...
9
votes
N-dimensional N^N array filled with N
Haskell, 52 bytes
f n=iterate(filter(>'"').show.(<$[1..n]))(show n)!!n
Try it online!
Inspired by @nimi's answer, but using more predefined functions.
...
9
votes
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
generation × 45code-golf × 38
random × 13
string × 7
number × 5
popularity-contest × 5
ascii-art × 4
math × 3
code-challenge × 3
array × 3
sequence × 2
integer × 2
geometry × 2
grid × 2
matrix × 2
parsing × 2
natural-language × 2
code-generation × 2
data-structures × 2
restricted-source × 1
combinatorics × 1
graphical-output × 1
game × 1
graph-theory × 1
permutations × 1