Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [binary]

For challenges about binary, or the base 2 number system.

Filter by
Sorted by
Tagged with
4 votes
4 answers
580 views

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_{...
Fmbalbuena's user avatar
  • 5,085
-2 votes
5 answers
332 views

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 ...
Lev's user avatar
  • 11
5 votes
9 answers
360 views

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^\...
Karl's user avatar
  • 871
23 votes
11 answers
2k views

(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 / <...
noodle person's user avatar
9 votes
7 answers
1k views

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 ...
3-1-4-One-Five's user avatar
13 votes
27 answers
1k views

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 ...
ThePlaneGuy45's user avatar
14 votes
14 answers
3k views

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 ...
Dannyu NDos's user avatar
  • 7,371
6 votes
2 answers
425 views

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 ...
mousetail's user avatar
  • 14.4k
10 votes
6 answers
853 views

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 ...
Tbw's user avatar
  • 3,023
16 votes
6 answers
1k views

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 ...
Tbw's user avatar
  • 3,023
18 votes
39 answers
3k views

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 ...
alephalpha's user avatar
  • 51.9k
2 votes
2 answers
279 views

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 ...
user avatar
20 votes
23 answers
2k views

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 ...
Kevin Cruijssen's user avatar
17 votes
5 answers
882 views

In this challenge, we consider an encoding from positive integers (up to a limit) to binary sequences. Some examples: ...
Bubbler's user avatar
  • 79.3k
14 votes
43 answers
4k views

The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1). You should take the binary number as a string (optionally with a ...
noodle person's user avatar
1 vote
1 answer
218 views

I am sorry for the very long description. But i think some information of how /proc/self/cmdline works and how it can be used to get a integer input was necessary. ...
12431234123412341234123's user avatar
2 votes
0 answers
272 views

Problem You are given a binary string A of length N. You can perform the following type of operation on the string A: Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$) Change \$...
hemanth's user avatar
  • 21
22 votes
14 answers
2k views

Here is Minkowski's question mark function: It is a strictly increasing and continuous function from the reals to themselves that, among other unusual properties, maps rational numbers to dyadic ...
Parcly Taxel's user avatar
  • 4,749
23 votes
9 answers
3k views

In this challenge, you're given a list of overlapping waves. Each wave is a finite list with n truthy values, then n falsy ...
Peter's user avatar
  • 1,067
10 votes
1 answer
484 views

Given a set of bit vectors \$A\$ and a binary matrix \$M\$, we can define the set \$MA = \{ Mx : x \in A \}\$, where \$ M x \$ is the result of the matrix multiplication of \$ M \$ by \$ x \$ over \$\...
Command Master's user avatar
16 votes
7 answers
1k views

Take the sequence of all natural numbers in binary, (1, 10, 11, ..) then write them vertically beside each-other like this (least significant bit on top; 0s have ...
mousetail's user avatar
  • 14.4k
33 votes
78 answers
5k views

It seems we've managed to go all this time without a plain vanilla Number-To-Binary challenge! Whilst this will inevitably be only one element in many languages, it should put a few esolangs through ...
ATaco's user avatar
  • 11.7k
8 votes
3 answers
441 views

It can be easily proven using Hall's marriage theorem that given fixed \$n\$ and \$k<n/2\$, there is an injective (one-to-one) function from all \$n\$-bit strings with \$k\$ ones to \$n\$-bit ...
Parcly Taxel's user avatar
  • 4,749
15 votes
3 answers
621 views

The task is to count the number of disjoint 11 blocks in a 64-bit word, using the minimum number of straight-line instructions. That is, how many nonoverlapping ...
Falk Hüffner's user avatar
15 votes
21 answers
868 views

Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As soon as the Elves get bored with the last week's game, Bin comes up with a new game. The rules are similar, ...
Bubbler's user avatar
  • 79.3k
9 votes
3 answers
537 views

Introduction In the binary representation of a \$k-\$bit \$(k>1)\$ square number \$n^2, \$ not all bits can be \$1\$. The maximum number of \$1\$-bits (Hamming weight, \$B\$ for short) is given in ...
Hugo Pfoertner's user avatar
13 votes
14 answers
1k views

Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa likes to sort his presents in a special way. He keeps "uninterleaving" the pile of presents into ...
math scat's user avatar
  • 9,528
19 votes
26 answers
1k views

Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. The Elves like playing number games. One day, Bin (a friend of Fen) suggests a new game: given a positive integer <...
Bubbler's user avatar
  • 79.3k
5 votes
3 answers
360 views

Background With the success of Simple Boolean Algebra Calculator, I present a more difficult problem. Boolean Algebra concerns representing values with letters and simplifying expressions. The ...
Jacob Creutzfeldt's user avatar
30 votes
20 answers
3k views

Background Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used: Above is what actual boolean algebra looks ...
Jacob Creutzfeldt's user avatar
29 votes
31 answers
3k views

Given a binary message, and the number of parity bits, generate the associated parity bits. A parity bit is a simple form of error detection. It's generated by counting the number of ...
math scat's user avatar
  • 9,528
12 votes
39 answers
3k views

Take a list of 2-digit hexadecimal numbers as input, and output the binary value, replacing each 1 with an 'X', and each 0 with a space. For example Input = ...
The Thonnu's user avatar
  • 18.7k
21 votes
20 answers
2k views

In this challenge you will take as input a non-empty list of binary values (these can be booleans or integers on the range 0-1), you should output all the ways to partition the list into non-empty ...
Wheat Wizard's user avatar
  • 103k
21 votes
11 answers
2k views

I recently stumbled across this image on wikimedia commons. It's a little bit of an information overload at first, but after examining it a bit it shows an interesting number system for writing ...
Wheat Wizard's user avatar
  • 103k
16 votes
11 answers
1k views

Carryless multiplication is an operation similar to binary long multiplication, but with XOR instead of addition: ...
rydwolf's user avatar
  • 19.3k
13 votes
15 answers
2k views

Your task is to write a program that calculates the amount of different ways to display any given whole positive number using the following rules: Meet the 'advanced binary system': Any whole positive ...
Squareoot's user avatar
  • 163
13 votes
7 answers
679 views

Background Here on CGCC, a commonly seen subgenre is radiation-hardening – writing a program that works even if one character is deleted. A similar problem is studied in the field of coding theory: ...
ais523 - high effort answers's user avatar
15 votes
16 answers
2k views

Background In programming, there is a recursive algorithm called binary exponentiation, which allows for large integer powers to be calculated in a faster way. Given a non-zero base \$x\$ and a non-...
Aiden Chow's user avatar
  • 14.5k
16 votes
14 answers
1k views

We all know that any positive integer can be represented as the sum of powers of two. This is how binary representations work. However there's not just one way to do this. The canonical method, ...
Wheat Wizard's user avatar
  • 103k
26 votes
26 answers
4k views

Given a decimal integer n as input, output the smallest (in terms of absolute value) decimal integer m such that the absolute ...
Fatalize's user avatar
  • 39.6k
17 votes
14 answers
3k views

This is the reverse of this challenge. Given an encoded list of codepoints and the characters used to encode it, you need to decompress it to its original string. For example, given the encoded list <...
naffetS's user avatar
  • 13.1k
21 votes
14 answers
3k views

This is different from Floating Point XOR, and more in the spirit of a comment by R.. GitHub STOP HELPING ICE on that challenge, but I thought of this idea independently. Generalized XOR The bitwise ...
Ovinus Real's user avatar
24 votes
17 answers
4k views

Given a string and the characters used to encode it, you need to compress the string by only using as many bits as each character needs. You will return the character codes for each character needed ...
naffetS's user avatar
  • 13.1k
33 votes
35 answers
4k views

The Collatz Conjecture The famous Collatz Conjecture (which we will assume to be true for the challenge) defines a sequence for each natural number, and hypothesizes that every such sequence will ...
EmilyR's user avatar
  • 1,533
15 votes
24 answers
2k views

A binary eye is an odd set of digits, with all of its digits except the center one set to 1 or 0, and the center one set to the opposite of the others. Thus, there are two binary eyes for a given odd ...
LWS SWL's user avatar
  • 420
13 votes
17 answers
2k views

Given two integers, compute the two numbers that come from the blending the bits of the binary numbers of equal length(same number of digits, a number with less digits has zeros added), one after the ...
LWS SWL's user avatar
  • 420
20 votes
30 answers
4k views

Take an input, and convert it from Two's Complement notation (binary where the first bit is negated, but the rest are taken as normal) into an integer (in a somewhat standard output form). Input can ...
Romanp's user avatar
  • 1,377
20 votes
11 answers
2k views

Given a positive integer \$n\$, your task is to find out the number of partitions \$a_1+a_2+\dots+a_k=n\$ where each \$a_j\$ has exactly \$j\$ bits set. For instance, there are \$6\$ such partitions ...
Arnauld's user avatar
  • 206k
11 votes
33 answers
2k views

Yeah... it's confusing. Let me explain it a little better: With a string, get the unicode code points of each letter Let's use "Hello World!". The code ...
12944qwerty's user avatar
1 vote
0 answers
140 views

The input message consists of ASCII characters The encoded output message consists of blocks of 0 A block is separated from another block by a space Two consecutive blocks are used to produce a series ...
DialFrost's user avatar
  • 5,189

1
2 3 4 5