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 ...
52
votes
Output the sign
Retina, 9 bytes
[1-9].*
1
Try it online!
Replaces a non-zero digit and everything after it with 1. This leaves a potential ...
51
votes
Print all integers
Haskell, 19 bytes
do n<-[1..];[1-n,n]
Produces the infinite list [0,1,-1,2,-2,3,-3,4,-4,5,-5,6,-6,7,-7...
Haskell allows ...
49
votes
As Easy as One-Two-Three
Python, 24 bytes
range(123,790,111).count
An anonymous function that outputs 0 or 1. It creates the list ...
45
votes
Output the sign
C (GCC), 24 23 22 18 bytes
Thanks to @aross and @Steadybox for saving a byte!
f(n){n=!!n|n>>31;}
Not guaranteed to work on all systems or compilers, works on ...
44
votes
43
votes
Output the missing integer
Python 2, 18 16 bytes
+beauty thanks to @Sarge Borsch
`99066**2`.strip
Try it online!
99066**2 is just a shorter way to ...
43
votes
Moving modest minimum
Python 2, 41 bytes
lambda l:[sorted(l)[x==min(l)]for x in l]
Try it online!
For each element x we check whether ...
42
votes
What are the five most powerful characters in your language?
Python3, 21 27 values
Characters: 3479%
Unique numbers: [1,2,3,4,5,6,7,8,9,11,12,19,20,21,24,29,34,35,36,37,39,43,46,47,49,73,74]...
38
votes
Powerprogramming: O(1^N), O(N^1), O(2^N), O(N^2) all in one
Python 3, 102 bytes
try:l=eval(input());k=1#)]0[*k**l(tnirp
except:k=2#2=k:tpecxe
print(k**l*[0])#1=k;))(tupni(lave=l:yrt
Try it online!
This is of O(1^n), ...
36
votes
Output the sign
Mathematica, 4 bytes
Clip
How about not using the built-in Sign and still scoring 4 bytes? ;)
...
36
votes
Is this number an exact power of -2: (Very) Hard Mode
C++, 15 operations
I have no idea why while loops are allowed as they destroy the whole challenge. Here is an answer without any:
...
36
votes
Is this a triangle?
Python, 24 bytes
lambda l:sum(l)>max(l)*2
Try it online!
Checks if a+b+c > max(a,b,c)*2. If, say, ...
35
votes
As Easy as One-Two-Three
Python, 24 bytes
lambda n:n%111==12<n<900
Just a lot of condition chaining.
35
votes
35
votes
A Portuguese sequence of integers
Wolfram Language (Mathematica), 42 bytes
Of course there is a built-in for this...
And as @Charlie mentioned we can golf "Portuguese" to ...
34
votes
What are the five most powerful characters in your language?
Python, 18 numbers
237#-
Produces as valid results:
1, 2, 3, 4, 5, 7, 16, 23, 24, 25, 27, 32, 35, 37, 69, 71, 72, 73
EDIT: ...
34
votes
What are the five most powerful characters in your language?
05AB1E, 27 38 41 numbers
4·>Ìn
Generates the unique numbers:
...
34
votes
34
votes
34
votes
Print the Lost numbers
Lost, 29 27/2 = 13.5 bytes
%?\>>>>>>>>>>
>>\"*"@"
Try it online! or verify that it is deterministic
...
34
votes
iHateOddNumbers
Python 2, 16 bytes
lambda n:n<<n%-2
Try it online!
The expression n%-2 equals 0 for even ...
33
votes
Turn an integer n into a list containing it n times
Jelly, 1 byte
x
Try it online!
Note that this is not the “repeat n n times” built-in — ...
32
votes
Greater than less than greater than something fishy
Retina, 20 bytes
Byte count assumes ISO 8859-1 encoding.
$.'
S`>
%O#`\d+
¶
>
Try it online! (The first line enables a linefeed-separated test-suite.)
...
32
votes
Oddly Even, Positively Negative
Python 2, 23 bytes
lambda n:~n/2+n%2*(n|2)
Odd inputs give roughly n/2, even ones roughly ...
32
votes
Which Card is it?
Python 3, 115 90 bytes
from unicodedata import*
lambda n:name(chr(n%13+n%13//11+[6,0,4,2][-n//13]*8+127137))[13:]
An unnamed function returning the ...
31
votes
Print all integers
Brainfuck, 6 bytes
This makes use of the cell wrapping and prints all possible values. In Brainfuck, the native integer representation is by byte value.
.+[.+]
Try ...
31
votes
Print all integers
Cubix, 14 12 bytes
.(.\OSo;?.>~
Test it online! You can now adjust the speed if you want it to run faster or slower.
How it works
The first thing the ...
31
votes
Accepted
Inverse Deltas of an Array
Jelly, 7 3 bytes
ḤḢ_
Try it online!
Background
The deltas of (a, b, c, d) are b - a, c - b, and d - c. Cumulatively reducing (a, b - a, c - b, d - c) by ...
30
votes
How many petals around the rose
Python 3, 30 bytes
lambda l:sum(n**3&6for n in l)
Try it online!
(test cases shamelessly borrowed from xnor's answer)
How?
Given \$1\le n\le6\$, the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
integer × 432code-golf × 403
number × 116
math × 93
sequence × 91
arithmetic × 58
array × 47
decision-problem × 36
string × 28
number-theory × 26
primes × 19
binary × 19
matrix × 18
ascii-art × 13
code-challenge × 13
base-conversion × 13
geometry × 9
bitwise × 9
kolmogorov-complexity × 8
sorting × 8
fastest-code × 8
fibonacci × 8
subsequence × 8
polynomials × 8
division × 8