2022 Developer Survey is open! Take survey.

# Questions tagged [binary]

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

201 questions
Filter by
Sorted by
Tagged with
2k views

### I want 8 bits for every character!

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 <...
• 4,076
2k views

### Bitwise XOR of floats

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 ...
• 303
4k views

### Who needs 8 bits for one character?

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 ...
• 4,076
3k views

### Collatz Encoding

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 ...
• 1,333
2k views

### The Binary Eyes

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 ...
• 457
1k views

### The interstice of two binary numbers

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 ...
• 457
2k views

### Convert from variable-width Two's Complement to Integer

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 ...
• 1,260
2k views

### 1 bit, 2 bits, 3 bits, …

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 ...
• 166k
1k views

### Convert the decimal digits of a string's Unicode codepoints to binary, reinterpret as decimal, and take the sum

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 ...
• 457
1 vote
119 views

### Binary with 0's only [closed]

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 ...
• 3,031
699 views

### Get all binary between a binary string and its reverse

Your Challenge is to take a binary string as input and get all binary numbers between itself and the reverse of its string representation (the reverse may be less than or greater than the original ...
2k views

2k views

### Emanresu numbers

My userid is 100664. In binary this is 11000100100111000. An interesting property of this number is that it can be created entirely by concatenating strings which ...
• 27.3k
1k views

### Encode USB packets (part 2)

Inspired by this video by Ben Eater. This challenge forms a pair with Decode USB packets. The USB 2.0 protocol uses, at a low level, a line code called non-return-to-zero encoding (specifically, a ...
• 18.5k
3k views

### Decode USB packets

Inspired by this video by Ben Eater. This challenge forms a pair with Encode USB packets. The USB 2.0 protocol uses, at a low level, a line code called non-return-to-zero encoding (specifically, a ...
• 18.5k
1k views

### Sum of set bits from 1 to n

Given an integer $n$ $(n \ge 1)$, return/output the total number of set bits between $1$ and $n$ inclusive. To make the problem more interesting, your solution must run with a time ...
• 17k
888 views

### Duplicates in "n × hamming weight of n" sequence

Background The sequence in the title is A245788 "n times the number of 1's in the binary expansion of n" ("times" here means multiplication), which starts like this: ...
• 62.1k
3k views

### Fibonacci Encoding

Fibonacci coding is a universal code, which can encode positive integers of any size in an unambiguous stream of bits. To encode an integer $n$: Find the largest Fibonacci number less than or ...
• 18.5k
2k views

### Test if a Gray code is Beckett

Background An $n$-bit Gray code is an ordering of $2^n$ binary sequences so that adjacent sequences always differ by exactly one bit. A Beckett-Gray code is a special kind of Gray code. In ...
• 62.1k
183 views

### Filetype Color Codes

On Unix-like systems, the ls command lists files. GNU's version of ls also colors them according to their properties and the ...
• 4,976
892 views

### Elias omega coding: decoding

Related: Elias omega coding: encoding Background Elias omega coding is a universal code which can encode positive integers of any size into a stream of bits. Given a stream of bits $S$, the decoding ...
• 62.1k
2k views

### Elias omega coding: encoding

Background Elias omega coding is a universal code which can encode positive integers of any size into a stream of bits. Given a positive integer $N$, the encoding algorithm is as follows: Start ...
• 62.1k
752 views

### Close(st) Binary Boxes

Challenge: Given a list of non-negative integers, determine by how much you should increase each item to create the closest binary box with the resulting integer-list. What is a binary box? A binary ...
• 103k
1k views

### Find a sequence in the binary digits of π

Given a binary sequence of finite length, find the starting position where this sequence first appears in the binary digits of π (after the decimal). You can assume that an answer exists for any input ...
• 1,787
159 views

### increment a binary number without arithmetic manipulations [closed]

Input: binary string Output: binary string that represents the binary input + 1 Example: Given 10111 as an input, output 11000 ...
• 115
2k views

### Display the exponent from a binary floating point number as a decimal value

Had my software final exams recently, one of the last questions had me thinking for a while after the exam had finished. Background IEEE754 numbers are according to the below layout The exponent is ...
5k views

### Is that number a Two Bit Number™️?

Let's start by defining a Two Bit Number™️: It is a positive integer When expressed as a binary string it has exactly 2 true bits OR When expressed as a decimal number, it has exactly 2 of the ...
• 11.1k
1k views

• 84.9k
666 views

### Convert a decimal integer to binary only using arithmetic operators

There are 10 types of people in the world, those who understand binary and those who do not. Where are you? Let's see! Challenge Your task is to convert a decimal integer to binary, only using a ...
• 11.9k
6k views

### Convert a 32 bit binary IPv4 address to its quad-dotted notation

Challenge Write a program or function that converts a 32 bit binary number to its quad-dotted decimal notation (often used for representing IPv4) Quad-dotted decimal A quad-dotted decimal is formed ...
• 1,599
1k views

### Fill the Golfeek gutter

Golfeek is the working name of an esolang I'm occasionally working on. One distinctive feature of this language is that each statement is encoded as a sequence of bits rather than a sequence of bytes. ...
• 166k
168 views

### Generating all Character possibilities with two characters [duplicate]

Introduction So the Challenge is to give out all combinations with two Inputs. The length of the string is also optional and you should be able to edit this. I've selected this channel because I ...
• 437
218 views

### Add 2 positive integers by playing with bits [closed]

Given 2 positive integers in any format you'd like, return their sum using only logic gates and bit shifts (see example below). Don't worry about overflow. EDIT: Using pre-written addition is ...
• 537
7k views

### Is it a Cyclops number? "Nobody" knows!

Task: Given an integer input, figure out whether or not it is a Cyclops Number. What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one ...
• 2,483