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!
...
- 179k
7
votes
Largest Binary Area
MATL, 14 13 bytes
1 byte saved thanks to @Suever
:B4&1ZIXz5#XM
Inputs n and outputs the ...
- 102k
2
votes
Largest Binary Area
Jelly, 12 11 bytes
B«\)LÐṀFS)Ṁ
A monadic Link that accepts \$n\$ and yields the largest binary area when arranging the numbers \$1\$ to \$n\$ inclusive.
Try it ...
- 97.9k
2
votes
Largest Binary Area
Charcoal, 28 bytes
FN«≔⁺∧&ι⊕ιθL§⪪⍘⊕ι²0⁰θ⊞υθ⟦I⌈υ
Try it online! Link is to verbose version of code. Outputs the first n terms. ...
- 156k
2
votes
2
votes
Largest Binary Area
Python, 95 93 92 88 bytes
m=n=0
while g:=lambda k:k and(k&k+1<1)+g(k>>1):print(m:=max(m,s:=n&(n:=n+1)<1or g(n)+s))
Attempt This Online!
Outputs ...
- 9,146
1
vote
Largest Binary Area
Python 3.8, 85 bytes
lambda n:max((j:=2**len(bin(n))>>3)-1,sum(bin(i*2)[2:].find('0')for i in range(j,n)))
An anonymous function that accepts a positive ...
- 97.9k
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
binary-matrix × 69code-golf × 62
matrix × 13
grid × 11
array × 11
decision-problem × 10
ascii-art × 6
code-challenge × 5
math × 4
number × 4
binary × 4
graph-theory × 4
string × 3
sequence × 3
game × 3
restricted-time × 3
geometry × 2
combinatorics × 2
unicode × 2
restricted-complexity × 2
linear-algebra × 2
open-ended-function × 2
kolmogorov-complexity × 1
integer × 1
permutations × 1