26
votes
American odds to probabilities
Python, 25 bytes
lambda x:x/(~99-abs(x))%1
Attempt This Online!
Thanks @Jonathan Allan for -1.
Original Python, 26 bytes
...
18
votes
Vanilla Natural Logarithm Challenge
Excel, 19 16 bytes
With many thanks to Dominic van Essen for the 3-byte save:
=1E9*(A1^1E-9-1)
Previous:
=9^9*(A1^(1/9^9)-1)
...
16
votes
Compute the Kolakoski sequence
Python 2, 42 bytes
x=y=-1
while 1:x=x/2^y;y<<=x%2;print x%2+1
Try it online!
Full disclosure - I didn't find the solution myself. I let my brute forcer do ...
14
votes
Add two real numbers ... probably
Python, 75 bytes
def f(*I,n=0):
for a,b in zip(*I):yield from[a,*n*[1^a]][:-(n:=1+n*(a^b))]
Attempt This Online!
Takes two iterables and returns one.
How?
Count ...
14
votes
Print a meter of numbers to a specified limit
Canvas, 4 bytes
R↶ *
Try it online.
Explanation:
...
13
votes
Shortest digid-app GetPercentageRounds function
JavaScript (Node.js), 53 bytes
f=(n,i=10)=>i?f(n,--i)+(n>=0&n<=i/10?"⚪":"🔵"):''
Try it online!
Need ...
12
votes
Accepted
Sum every second digit in a number
Vyxal, 2 bytes
y∑
well.
Try it Online! | 1 byte with s
Explanation
...
12
votes
Shortest digid-app GetPercentageRounds function
Scratch, 172 166 142 bytes
This program outputs to a global variable o which is automatically displayed and assumes that the i ...
12
votes
Vanilla Natural Logarithm Challenge
Builtins
These answers are in alphabetical order based on programming language.
If your answer is identical to an existing one, please combine them.
05AB1E, 4 bytes
...
Community wiki
12
votes
Output the smallest increasing sequence where each term is coprime to preceding 3 terms
Python 3, 78 77 bytes
-1 byte thanks to @Bubbler!
Prints the 0-indexed n-th term of the sequence. Who needs gcd anyway?
...
12
votes
American odds to probabilities
Jelly, 7 bytes
,³ṢAÄ÷/
Try it online!
Function I/O only because lmao ³. (Replace with ȷ2 if ...
12
votes
Diagonal Binary Sequence
Python, 39 bytes
lambda n,k:n^-2&(1^1<<k)<<len(bin(n))-3
Attempt This Online!
Explanation
...
11
votes
11
votes
Summing the Digits of a Number
Trilangle, 15 bytes
'0.<"@(+>i(^-<!
Test it on the online interpreter!
Roughly equivalent to this C code:
...
11
votes
Vanilla Natural Logarithm Challenge
><> (Fish), 71 bytes
Trying to solve this in ><> was the original inspiration for this challenge. Posting this now instead of waiting the usual 24 hours to hopefully inspire more ...
11
votes
Half even rounding
Builtins in various languages
05AB1E (legacy), 1 byte
ò
Only works in the legacy version of 05AB1E, which is builtin in Python. The new version of 05AB1E, which is ...
Community wiki
11
votes
Half even rounding
JavaScript (ES6), 30 bytes
Uses the Math.round() built-in, then clears the least significant bit of the result if the squared fractional part of the original input ...
10
votes
Gödel encoding - Part I
Jelly, 11 10 9 8 bytes
-1 thanks to Unrelated String! (Use of a dyadic chain in place of a monadic compound link avoiding the need for argument manipulation with `...
10
votes
10
votes
Accepted
Add two really big numbers
Trivial Built-in Answers
For languages where bignum addition is already supported.
05AB1E, Brachylog, Factor, J, Jelly, Julia, Nekomata, RProgN 2, Vyxal, 1 byte
+
...
Community wiki
9
votes
Sum every second digit in a number
Python 3, 28 37 32 30 35 bytes
lambda n:sum(map(int,str(n)[1::2]))
Assuming input is a string number
9
votes
Calculate my income tax
JavaScript (ES6), 99 bytes
Works with floats and rounds the final result.
...
9
votes
Round to nicer numbers
Wolfram Language (Mathematica), 18 bytes
Round[2^#2#,2^#3]&
Try it online!
Returns a binary fraction. By default, the built-in ...
9
votes
Shortest digid-app GetPercentageRounds function
Type System (TypeScript 4.9.4) - 243 188 Bytes
Now they can validate their function with type safety!
56 Bytes thanks to @ASCII-only
8 Bytes thanks to @ASCII-only
114 Bytes only by @ASCII-only (...
9
votes
Accepted
9
votes
Print all pandigital numbers
x86-64 machine code, 28 bytes
31 C0 FF C0 50 31 C9 99 F7 FE 0F AB D1 01 C2 75 F6 58 FF C1 0F A3 F1 19 D7 73 E7 C3
Try it online!
Following the standard calling ...
9
votes
Summing the Digits of a Number
C (gcc), 30 bytes
f(int*s){s=*s?*s-48+f(s+1):0;}
Try it online!
C (clang), 31 bytes
f(*s){return*s?*s-48+f(s+1):0;}
Try it ...
9
votes
Largest Binary Area
JavaScript (V8), 67 bytes
Prints the sequence infinitely.
for(m=n=0;g=k=>k?!(k&k+1)+g(k>>1):s;print(m=m>s?m:s))s=n&++n?g(n):1
Try it online!
...
9
votes
9
votes
The number of solutions to Hertzsprung's Problem
Nekomata + -n, 6 bytes
r↕∆A1>
Attempt This Online!
Brute force. Slow for large input.
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
number × 1300code-golf × 1209
math × 295
sequence × 241
arithmetic × 151
integer × 116
string × 104
number-theory × 98
decision-problem × 95
array × 87
primes × 66
base-conversion × 55
code-challenge × 46
binary × 41
ascii-art × 35
kolmogorov-complexity × 32
combinatorics × 28
random × 23
fibonacci × 22
matrix × 21
restricted-source × 19
rational-numbers × 19
sorting × 18
permutations × 18
fastest-code × 17