New answers tagged binary
0
votes
0
votes
Encode the systematic binary Varshamov–Tenengolts code
Husk, 29 bytes
ΣSżż+öm;↔ḋ§%o→Lȯ_ΣWIΣmΘCΘm←İ2
Try it online!
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:
...
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
...
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 ...
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
...
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.
...
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
...
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 ...
2
votes
Is that number a Two Bit Number™?
Chocolate, 8 bytes
ċ11€ṛ0;B
Try it online!
Link includes γ (map) for test cases.
...
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. ...
2
votes
Is that number a Two Bit Number™?
Perl 5 -p, 35 bytes
$_.=sprintf" %b",$_;$_=/\b10*10*\b/
Try it online!
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:
...
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 ...
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 ...
4
votes
Is that number a Two Bit Number™?
Vyxal, 8 bytes
₍fb3eṠ2c
Try it Online!
Try it Online! - test cases only
...
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 ...
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 <...
2
votes
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!
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 ...
2
votes
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!
Top 50 recent answers are included
Related Tags
binary × 205code-golf × 194
number × 37
sequence × 36
base-conversion × 28
math × 21
string × 19
integer × 16
decision-problem × 14
bitwise × 11
arithmetic × 9
encoding × 8
ascii-art × 7
number-theory × 7
combinatorics × 6
primes × 6
restricted-source × 5
fastest-code × 4
subsequence × 4
conversion × 4
coding-theory × 4
code-challenge × 3
kolmogorov-complexity × 3
game × 3
counting × 3