Questions tagged [binary]
For challenges about binary, or the base 2 number system.
243 questions
2
votes
2
answers
195
views
Speak in Binary
Background
This video goes into ways you can humanize binary, including creating a more compact writing notation using . and | ...
4
votes
4
answers
589
views
Find the boolean logic to check if a number is prime!
Your task is to find a boolean expression that uses AND (\$\land\$), OR (\$\lor\$), XOR (\$\oplus\$), and NOT (\$\lnot\$) operators and binary digit positions (\$d_1,d_2,d_3,d_4,d_5,d_6,d_7,d_8,d_9,d_{...
-2
votes
5
answers
332
views
Add an integer to its count of set bits [duplicate]
The task is to find the shortest solution to the following problem:
Given an integer \$n\$ (\$0<n<10^7\$) find \$n+C(n)\$, where \$C(n)\$ is the count of set bits in the binary representation of ...
5
votes
9
answers
362
views
Reorder a string of length \$2^n\$ by permuting the \$n\$ binary digits of every index
Given a binary string \$s\$ of length \$2^n\$ and a permutation \$\sigma\$ of \$\{1,\dots,n\}\$, generate the binary string \$u\$ of length \$2^n\$ which is a reordering of \$s\$ such that \$u[i^\...
23
votes
11
answers
2k
views
Binary Slashes Display
(easy mode of Seven Slash Display)
Given a positive integer (or alternatively, a string/list of bits of its binary representation) output it with this diagonal ASCII-art formation:
(output for 53 / <...
9
votes
7
answers
1k
views
Hoop, Hoop, Hoop, Hoop, Eye-Eye-Eye-Eye
The Horrible Histories song "Learn Your Hieroglyphics" mentions a fanmade number system. Numbers are written as a sum of 10's ("hoops") and 1's ("eyes"), for example 99 ...
13
votes
27
answers
1k
views
Construct a uInt from an array of bits
Task is simple!
Take an array of binary values (can be boolean, 0/1, etc.) and use those bits to construct an n-th bit long unsigned integer (return type does not need to be an unsigned integer, just ...
14
votes
14
answers
3k
views
Break an integer into even- and odd-indexed bits
Objective
Given an integer \$n\$ interpreted as two's complement binary, output two integers, namely the integer consisting of \$n\$'s bits at places of \$2^0, 2^2, 2^4, \cdots\$, and the integer ...
6
votes
2
answers
425
views
Compact Binary Representation
Background
Often, when storing a number in binary with some maximum, we simply round the maximum to the next power of two then allocate the number of bits nececairy to store the whole range. Lets call ...
10
votes
6
answers
856
views
Convert from Spoken Binary
This is an exact inverse of the question Convert to Spoken Binary. This introduction is copied from there.
Introduction
In the video the best way to count, binary is proposed as the
best system of ...
17
votes
6
answers
1k
views
Convert to Spoken Binary
Introduction
In the video the best way to count, binary is proposed as the best system of counting numbers. Along with this argument is a proposal on how to say numbers in this system. First, we give ...
18
votes
39
answers
3k
views
Rudin-Shapiro sequence
The Rudin-Shapiro sequence is a sequence of \$1\$s and \$-1\$s defined as follows: \$r_n = (-1)^{u_n}\$, where \$u_n\$ is the number of occurrences of (possibly overlapping) \$11\$ in the binary ...
2
votes
2
answers
279
views
Binary expansion and partition numbers [closed]
Not sure if it's correct to ask such a question on this site, but let's try.
Let a(n) be a sequence of positive integer such that a(1) = 1. To reproduce the sequence a(n) through itself, use the ...
20
votes
23
answers
3k
views
Diagonal Binary Sequence
Challenge:
Given a positive number \$n\$, convert it to binary, and output a sequence where all 1s form a top-left to bottom-right diagonal line, including a ...
17
votes
5
answers
882
views
Prefix code generator
In this challenge, we consider an encoding from positive integers (up to a limit) to binary sequences. Some examples:
...