# Questions tagged [binary]

For challenges regarding binary, or the base 2 number system. Also, use on challenges relating to binary, such as challenges about negabinary or similar systems. Do not use on generic [base-conversion] challenges, unless specifically about binary.

187 questions
Filter by
Sorted by
Tagged with
570 views

### Convert to a non-adjacent form

Consider a form of binary where digits can be any of $1$, $0$ and $-1$. We'll still call this "binary" because we convert the digits from base two. For example, \begin{align} [1, 0, -...
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 ...
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 ...
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 ...
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 ...
862 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: ...
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 ...
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 ...
169 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 ...
836 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 ...
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 ...
732 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 ...
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 ...
144 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 ...
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 ...
1k views

646 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 ...
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 ...
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. ...
155 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 ...
216 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 ...
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 ...
539 views

### Find how "smooth" a number is based on binary

I haven't been on PP&CG for a while, so I thought I would post something! Your task is to find how "smooth" a natural number is. Your method is to: 1: Convert the number to binary 2: Find the ...
734 views

### Fizzbuzz in any base

Challenge Input: An integer $b$ between 2 and 62 (inclusive). Output: Count from $1$ to the equivalent of $5000_{10}$ in base $b$, using any reasonable representation for the digits. ...
2k views

### Quine outputs itself in binary

Your task, if you wish to accept it, is to write a program that outputs its own source code in the binary UTF-8 representation. Rules The source must be at least 1 byte long. Your program must not ...
8k views

### Sum of Powers of 2

The Challenge Given an integer input x where 1 <= x <= 255, return the results of powers of two that when summed give <...
7k views

### Find the number of leading zeroes in a 64-bit integer

Problem: Find the number of leading zeroes in a 64-bit signed integer Rules: The input cannot be treated as string; it can be anything where math and bitwise operations drive the algorithm The ...
3k views

### Densely packed decimal (DPD) to decimal

For nandgame fans: Please try out DPD to decimal in logic gates too! Background Densely packed decimal (DPD) is a way to efficiently store decimal digits in binary. It stores three decimal digits (...
959 views

### The Binary Fences

Input: An integer n in the range 2 <= n <= 10 A list of positive integers Output: Convert the integers to their binary ...
1k views

### Minimum operations to get from one number to another

Let's define a simple language that operates on a single 8-bit value. It defines three bitwise operations (code explanation assumes 8-bit value variable): ...
3k views

### count ones in range

Challenge : Count the number of ones 1 in the binary representation of all number between a range. Input : Two non-decimal positive integers Output : The sum of ...
5k views

### prOGraMMIng PuZZleS & cOde ____

Input A non-empty encoded string consisting of printable ASCII characters (in the range 32-126), where some missing letters have been replaced with _. Output A ...
106 views

### Golf a bit-reversal table [duplicate]

The Premise: You are writing a C driver for a screen for use on an embedded system. The screen uses a tortured version of SPI that requires data to be sent LSb (least-significant-bit) first, but MSB (...
5k views

### Let's play Mölkky!

Mölkky Mölkky is a Finnish throwing game. The players use a wooden pin (also called "mölkky") to try to knock over wooden pins of almost similar dimensions with the throwing pin, marked with ...
4k views

### Binary Fibonacci

Challenge You need to generate a program or function that takes in a positive integer N, calculates the first N terms of the Fibonacci sequence in binary, concatenates it into a single binary number, ...