Hot answers tagged

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 ...
xnor's user avatar
  • 144k
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 ...
Martin Ender's user avatar
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 ...
xnor's user avatar
  • 144k
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 ...
xnor's user avatar
  • 144k
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 ...
betseg's user avatar
  • 8,753
44 votes

How long is my number?

Taxi, 1118 bytes ...
Engineer Toast's user avatar
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 ...
Rod's user avatar
  • 18.4k
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 ...
xnor's user avatar
  • 144k
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]...
Yytsi's user avatar
  • 3,762
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), ...
Leaky Nun's user avatar
  • 49.6k
36 votes

Output the sign

Mathematica, 4 bytes Clip How about not using the built-in Sign and still scoring 4 bytes? ;) ...
Martin Ender's user avatar
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: ...
orlp's user avatar
  • 39k
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, ...
xnor's user avatar
  • 144k
35 votes

As Easy as One-Two-Three

Python, 24 bytes lambda n:n%111==12<n<900 Just a lot of condition chaining.
Sp3000's user avatar
  • 61.7k
35 votes

Float 754 to Hamming

x86_64 machine language (Linux), 16 bytes ...
ceilingcat's user avatar
  • 7,457
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 ...
ZaMoC's user avatar
  • 24.4k
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: ...
Leo's user avatar
  • 12.4k
34 votes

What are the five most powerful characters in your language?

05AB1E, 27 38 41 numbers 4·>Ìn Generates the unique numbers: ...
Emigna's user avatar
  • 52.9k
34 votes

Output the sign

COW, 225 213 201 bytes ...
Gabriel Benamy's user avatar
34 votes

N-dimensional N^N array filled with N

J, 4 bytes $~#~ Try it online! Explanation ...
miles's user avatar
  • 16.9k
34 votes

Print the Lost numbers

Lost, 29 27/2 = 13.5 bytes %?\>>>>>>>>>> >>\"*"@" Try it online! or verify that it is deterministic ...
Jo King's user avatar
  • 47.1k
34 votes

iHateOddNumbers

Python 2, 16 bytes lambda n:n<<n%-2 Try it online! The expression n%-2 equals 0 for even ...
xnor's user avatar
  • 144k
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 — ...
Lynn's user avatar
  • 68.1k
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.) ...
Martin Ender's user avatar
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 ...
xnor's user avatar
  • 144k
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 ...
Jonathan Allan's user avatar
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 ...
flawr's user avatar
  • 43.7k
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 ...
ETHproductions's user avatar
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 ...
Dennis's user avatar
  • 210k
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 ...
Arnauld's user avatar
  • 188k

Only top scored, non community-wiki answers of a minimum length are eligible