New answers tagged

0 votes

Encode the systematic binary Varshamov–Tenengolts code

Desmos, 250 bytes ...
user avatar
  • 5,563
0 votes

Encode the systematic binary Varshamov–Tenengolts code

Husk, 29 bytes ΣSżż+öm;↔ḋ§%o→Lȯ_ΣWIΣmΘCΘm←İ2 Try it online!
user avatar
1 vote

Encode the systematic binary Varshamov–Tenengolts code

Charcoal, 40 bytes FS«W¬&Lυ⊖Lυ⊞υω⊞υι»⭆υ⎇ιι⎇κ﹪÷﹪±↨⌕Aυ1¹Lυκ²ω Try it online! Link is to verbose version of code. I/O is as digit strings. Explanation: ...
user avatar
  • 146k
1 vote

Encode the systematic binary Varshamov–Tenengolts code

MATL, 27 26 bytes 0i"NB?0]@]vtfs_ynQ\BfqW1w( Try it online! Or verify all test cases. How it works ...
user avatar
  • 99.9k
1 vote

Encode the systematic binary Varshamov–Tenengolts code

R, 126 bytes \(x){v=!(l=seq(3*sum(x|1))) v[p<--2^l/2]=seq(!x) v=v[l<-1:(m=which.max(v))] v[p]=x v[-l[p]]=-sum(which(v>0))%%(m+1)%/%-p%%2 v} Attempt This ...
user avatar
3 votes

Encode the systematic binary Varshamov–Tenengolts code

05AB1E, 29 27 26 bytes gÝo<£õÜD»SÐƶ«þO(sgÌ%bRs0ζS Try it online, or try all test cases. I'm quite sure this can be golfed Explanation ...
user avatar
3 votes

Encode the systematic binary Varshamov–Tenengolts code

JavaScript (ES6),  89  83 bytes A rather literal implementation of the algorithm described in the challenge. ...
user avatar
  • 169k
2 votes

Is that number a Two Bit Number™?

Pip, 12 bytes 11N[TBaa]DC0 Outputs 1 for two-bit numbers, 0 otherwise. Try It Online! Or, use as a filter to get all two-bit numbers up to 101. Explanation ...
user avatar
  • 33.2k
2 votes

Is that number a Two Bit Number™?

PARI/GP, 46 bytes n->(d=digits(n))*d~==2||sumdigits(n,2)==2&&n>0 Attempt This Online! For base 2, checks whether the sum of the digits is \$2\$. For ...
user avatar
  • 35.9k
2 votes

Is that number a Two Bit Number™?

Chocolate, 8 bytes ċ11€ṛ0;B Try it online! Link includes γ (map) for test cases. ...
user avatar
  • 8,936
2 votes

Is that number a Two Bit Number™?

Fig, \$11\log_{256}(96)\approx\$ 9.054 bytes Gu=11Oeo0wb See the README to see how to run this I will not let Vyxal beat me. Even though I ported it. No. Never. ...
user avatar
  • 3,337
2 votes

Is that number a Two Bit Number™?

Perl 5 -p, 35 bytes $_.=sprintf" %b",$_;$_=/\b10*10*\b/ Try it online!
user avatar
  • 12.7k
1 vote

Sum of Powers of 2

K (ngn/k), 26 bytes {_0.5+`exp x*`ln 2}'*|=|2\ Try it online! My first function-less K answer. Port of Xcoder's Jelly answer. Explanation: ...
user avatar
  • 693
3 votes

Is that number a Two Bit Number™?

MUMPS, 55 bytes i $tr(n,01) f q:n<1 s %=n#2_%,n=n\2 w $tr(n_%,0)=11 Try it online! Each line has a leading space so that the commands aren't interpreted as ...
user avatar
1 vote

Is that number a Two Bit Number™?

K (ngn/k), 9 32 bytes {({~#($x)^"1 0"} x)|{2=+/2\x} x} Try it online! Having to add more bytes because I read the challenge wrong. Doesn't work correctly ...
user avatar
  • 693
4 votes

Is that number a Two Bit Number™?

Vyxal, 8 bytes ₍fb3eṠ2c Try it Online! Try it Online! - test cases only ...
user avatar
  • 9,510
2 votes

Sum of Powers of 2

APL, 11 bytes 2*8-⍸⎕⊤⍨8⍴2 Explanation on example of number 86. Input number: 86 ⊤⍨8⍴2 ...
user avatar
1 vote

Sum of Powers of 2

Regex (Perl / PCRE2 / Boost / Pythonregex), 16 13 bytes x(x((?1))\2|) Takes its input in unary, as the length of a string of <...
user avatar
  • 9,510
2 votes

Sum of Powers of 2

Vyxal, 3 bytes ʀE⋏ Try it Online! ...
user avatar
  • 8,936
0 votes

Sum of Powers of 2

Desmos, 55 bytes f(n)=2^{b[mod(floor(n/2^b),2)=1]} b=[0...floor(log_2n)] Port of Mr. Xcoder's Jelly answer. Try it on Desmos!
user avatar
  • 8,936
4 votes

Sum of Powers of 2

Piet + ascii-piet, 88 bytes (4×22=88 codels) My first Piet answer! taqu ci?aqtqqiarufqqrNdsssec ?a??q??vejraimMdk??e lane???nv??rr ?Mddtqe ll esufnvsbiesue In grid ...
user avatar
  • 1,357
2 votes

Number of binary partitions

APL, 19 bytes {2≥⍵:⍵⋄1++/∇¨⍳⌊⍵÷2}
user avatar
0 votes

Write out the Thue-Morse sequence

Python, 43 bytes def f(n):n>0==f(n-1);print(n.bit_count()%2) Attempt This Online!
user avatar
  • 22.2k

Top 50 recent answers are included