Hot answers tagged

55 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 ...
user avatar
  • 138k
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 ...
user avatar
49 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 ...
user avatar
  • 138k
47 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 ...
user avatar
  • 138k
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 ...
user avatar
  • 8,703
44 votes

How long is my number?

Taxi, 1118 bytes ...
user avatar
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]...
user avatar
  • 3,722
41 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 ...
user avatar
  • 138k
40 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 ...
user avatar
  • 18.2k
37 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), ...
user avatar
  • 48.6k
36 votes

Output the sign

Mathematica, 4 bytes Clip How about not using the built-in Sign and still scoring 4 bytes? ;) ...
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: ...
user avatar
  • 38.8k
35 votes

Float 754 to Hamming

x86_64 machine language (Linux), 16 bytes ...
user avatar
  • 6,847
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 ...
user avatar
  • 23.2k
35 votes

iHateOddNumbers

Python 2, 16 bytes lambda n:n<<n%-2 Try it online! The expression n%-2 equals 0 for even ...
user avatar
  • 138k
34 votes

As Easy as One-Two-Three

Python, 24 bytes lambda n:n%111==12<n<900 Just a lot of condition chaining.
user avatar
  • 61k
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: ...
user avatar
  • 11.8k
34 votes

What are the five most powerful characters in your language?

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

Print the Lost numbers

Lost, 29 27/2 = 13.5 bytes %?\>>>>>>>>>> >>\"*"@" Try it online! or verify that it is deterministic ...
user avatar
  • 44.9k
33 votes

Output the sign

COW, 225 213 201 bytes ...
user avatar
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 — ...
user avatar
  • 66.1k
33 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, ...
user avatar
  • 138k
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.) ...
user avatar
32 votes

N-dimensional N^N array filled with N

J, 4 bytes $~#~ Try it online! Explanation ...
user avatar
  • 16.4k
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 ...
user avatar
  • 138k
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 ...
user avatar
  • 43.1k
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 ...
user avatar
31 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 ...
user avatar
28 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 ...
user avatar
  • 207k
28 votes

Is this number an integer power of -2?

Mathematica, 22 bytes EvenQ@Log2@Max[#,-2#]& Try it online! (Using Mathics instead, where this solution also works.) I tried to find a solution with bitwise ...
user avatar

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