Hot answers tagged

14 votes

How far from binary?

JavaScript (ES6), 43 bytes Starting with \$k=0\$ and using the expression (k < 1) - k to update \$k\$ after each iteration, we recursively generate \$k=0,1,-1,2,-...
user avatar
  • 168k
14 votes

Decipher a squashed sequence

Brachylog, 8 6 bytes Ṁ∧⟦₂?c Try it online! Thanks to @UnrelatedString for -2 bytes. Takes an integer as the output variable, and unifies the answer with the input ...
user avatar
  • 35.8k
14 votes

Decipher a squashed sequence

Regex (.NET) + x flag, 418 209 204 199 132 115 99 bytes -209 bytes (418 → 209) thanks to Neil ...
user avatar
  • 7,029
14 votes

Number of binary partitions

Haskell, 22 bytes l=scanl(+)1$(:[0])=<<l Try it online! Defines the infinite list l of ...
user avatar
  • 137k
12 votes

Doing a little trolling with the microwave timer

Haskell, 43 bytes Doesn't output 0:0 0?0=[] n?0=(n,0):(n-1)?59 n?m=(n,m):n?(m-1) Try it online! This is very simple. ...
user avatar
  • 88.3k
12 votes

Number of binary partitions

Python, 31 bytes f=lambda n:n<2or f(n-2)+f(n//2) Attempt This Online! This can be derived from the recursion below by taking the difference between f(n) and f(n-2) which cancels most of the terms ...
user avatar
  • 6,910
10 votes

Doing a little trolling with the microwave timer

R, 41 bytes f=\(m,s,`~`=rbind)t(m~s:0)~if(m)f(m-1,59) Attempt This Online! Makes a 2-column matrix of the minutes and seconds...zero. Then, if the minutes are non-...
user avatar
9 votes

How far from binary?

Haskell, 48 bytes f n=[m|k<-[0..],m<-[k,-k],all(<'2')$show$n-m]!!0 Try it online! xnor saved 7 bytes, thanks!
user avatar
  • 66k
9 votes

Implement Binary Exponentiation

Vyxal, 6 bytes d‡½⌊İe Try it Online! Takes inputs in reverse order. Explanation ...
user avatar
  • 6,520
8 votes

How far from binary?

Python 2, 49 bytes f=lambda n,m=0:f(n,(m<1)-m)if"1"<max(`n-m`)else m Attempt This Online! Port of Arnauld's answer, thanks to Kevin Cruijssen. ...
user avatar
  • 21.5k
7 votes

Numbers with Rotational Symmetry

Regex (ECMAScript / Python), 366 323 254 201 180 148 bytes ...
user avatar
  • 7,029
7 votes

Doing a little trolling with the microwave timer

Jelly, 13 12 11 bytes ȷ2ḍ41*ạµ¹Ð¿ Try it online! -1 thanks to Zion mycelia adamancy, and another -1 with inspiration from their suggestion Uses flat integer I/O. ...
user avatar
7 votes

Doing a little trolling with the microwave timer

C (gcc), 43 bytes f(n){printf("%d ",n);n&&f(n%100?n-1:n-41);} Try it online!
user avatar
  • 15.8k
7 votes

Decipher a squashed sequence

Haskell, 62 bytes f s=[[a..b]|a<-[1..],b<-[a..a+length s],([a..b]>>=show)==s]!!0 Try it online!
user avatar
  • 66k
6 votes

How far from binary?

05AB1E, 6 bytes LbI.x- Try it online or verify all test cases or see this step-by-step output. Explanation: ...
user avatar
6 votes

How far from binary?

K (ngn/k), 22 bytes {(|/49<$x-){-x-x<1}/0} Try it online! -3 bytes thanks to @coltim! Port of Arnauld's answer. My first-ever K submission! Been having a lot ...
user avatar
6 votes

Decipher a squashed sequence

Vyxal, 10 8 bytes øṖ⌊'ḣtṡ⁼ Try it Online! Incredibly slow for some inputs, reasonable for others. Explained ...
user avatar
  • 22.1k
6 votes

Decipher a squashed sequence

Julia, 71 bytes ! =length *(s,a=1,b=a,j=join(a:b))=!j<!s ? s*a*-~b : j!=s ? s*-~a : a:b Attempt This Online! Takes a string as input and returns a range (...
user avatar
  • 4,984
5 votes

How far from binary?

Whitespace, 193 bytes ...
user avatar
5 votes

Doing a little trolling with the microwave timer

K (ngn/k), 24 bytes (|/){x-$[*|x;!2;1 -59]}\ Try it online! -1 byte thanks to @dzaima! -3 bytes thanks to @coltim! Explanation Input is l. ...
user avatar
5 votes

Doing a little trolling with the microwave timer

Python 3, 52 bytes f=lambda m,s:m+1and[[m,s]]+f(m-0**s,(s or 60)-1)or[] Try it online!
user avatar
  • 6,359
5 votes

Decipher a squashed sequence

R, 66 bytes \(n)repeat for(i in 1:(T=T+1))if(n==Reduce(paste0,i:T))return(i:T) Attempt This Online!
user avatar
5 votes

Bloons TD 6 Upgrade Paths

K (ngn/k), 20 18 bytes ?,/+'!'1|3*<'+!3#3 Try it online! +!3#3 All triples with values in ...
user avatar
  • 54.4k
5 votes

Bloons TD 6 Upgrade Paths

Factor + math.combinatorics, 59 58 bytes 6 iota 3 selections [ natural-sort "\0"before? ] filter . Try it online! -1 ...
user avatar
  • 10.2k
4 votes

Fibonacci function or sequence

Fig, commit df1d8a1, \$5\log_{256}(97)\approx\$ 4.125 bytes G:1'+ New language! Yay! This is a fractional byte language I've been advertising on TNB for a while ...
user avatar
  • 3,077
4 votes

Big big numbers

Vyxal, 3 bytes ~\$10^{305}\$ øCṪ Try it Online! Thanks to emanresu A for 2 more orders of magnitude Simple number compression builtin, then chop off the last char. ...
user avatar
  • 3,077
4 votes

Print all integers

Regenerate, 22 bytes 0|($2[0-9]!-?[1-9]())+ Attempt This Online! Thanks to thejonymyster for the idea to use this language to answer this question. In pretty-...
user avatar
  • 7,029
4 votes

How far from binary?

Factor + math.unicode, 73 66 62 bytes [ 0 [ 2dup - >dec "-01" ⊂ ] [ dup 1 < 1 0 ? swap - ] until ] A port of @...
user avatar
  • 10.2k
4 votes

How far from binary?

C (gcc), 78 bytes p;r;m;f(n){for(r=m=0;r=!r;m=r?m:(m<1)-m)for(p=abs(n-m);p;p/=10)r&=p%10<2;n=m;} Try it online! Uses Arnauld's idea from his Javascipt ...
user avatar
  • 18.4k
4 votes

How far from binary?

C# (Visual C# Interactive Compiler), 57 bytes -4 thanks to Neil int@B(int@n,int@m=0)=>$"{n-m}".Max()<50?m:B(n,m<0?-m:~m); Try it online! Kinda ...
user avatar

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