# Questions tagged [binary]

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

232 questions
Filter by
Sorted by
Tagged with
1k views

### Binary Sequences

Given a binary number A as input with d > 1 digits, output a binary number B with d digits according to the following rules for finding the nth digit of B: The first digit of B is zero if the first ...
• 2,763
2k views

### Find the BCD difference of a number

BCD difference Given an integer n, convert it to BCD (binary-coded decimal) by replacing each decimal digit with its 4-digit binary representation ...
• 21k
17k views

### Clearing the most significant bit from an integer

Input The input is a single positive integer n Output The output isn with its most significant bit set to ...
3k views

### Take a byte out of it!

Your task is to, given an unsigned integer n, find the largest number which can be created by removing a single byte (8 consecutive bits) of data. Example Given ...
• 14.6k
2k views

### Finite tilings in one dimension

The purpose of this challenge is to determine if a collection of one-dimensonal pieces can be tiled to form a finite continuous chunk. A piece is a non-empty, finite sequence of zeros and ones that ...
• 104k
3k views

### Take one to make one

Challenge Given a list of positive integers, find if there exists a permutation where taking up to one bit from each of the integers, a binary number consisting of all ...
• 969
1k views

### Output the Source, One Bit at a Time

Write a non-empty program or function that when called outputs a single value, 1 or 0, and when called multiple times, the output numbers produce the binary representation of your program's source ...
• 16.5k
971 views

### Binary Prime-Chunks

We are searching for a sequence Take the natural numbers 1,2,3,4,5,6,7,8,9,10,11,12,13,14... Convert to base-2 ...
1k views

### The Binary Square Diagonal Sequence

The binary-square-diagonal-sequence is constructed as follows: Take the sequence of positive natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ... Convert each number to ...
• 26.1k
2k views

### Number of distinct non-empty subsequences of binary expansion

A subsequence is any sequence that you can get from another by deleting any amount of characters. The distinct non-empty subsequences of 100 are ...
• 39k
1k views

### Longest hypercube path

Challenge You are given two distinct bit strings of the same length. (For example, 000 and 111.) Your goal is to find a path ...
• 5,247
16k views

### How on earth did llhuii output the Evil Numbers in 42 bytes of Python?

This is a tips question for golfing in Python concerning the Evil Numbers question on Anarchy Golf. An number is evil if its binary expansion has an even number of 1's. The challenge is to print the ...
• 144k
5k views

### Calculate the longest series of 1's in an integer's binary value

Goal Given a non-negative integer, create a function that returns the starting position of number of largest consecutive 1's in that integer's binary value. When given an input ...
• 575
2k views

### The Binary Binary Expansion

Normally, we decompose a number into binary digits by assigning it with powers of 2, with a coefficient of 0 or 1 for each term: ...
• 406
1 vote
2k views

Convert a binary number (of any size) into a hexadecimal number. Input A POSITIVE binary number with just the 0s and 1s. A ...
978 views

Imagine you have two boxes B(x) and B(y), each containing an unknown bit - 0 or 1, and a machine ...
• 15.2k
2k views

### It's a Bit of a Stretch․․․

Input: We take two inputs: An input b with two distinct values: Left and Right.† And a ...
• 123k
1k views

### Generate unseen numbers

Let us say a substring is any continuous section of an original string. For example cat is a substring of concatenate. We will ...
• 96.5k
3k views

### Palindromic numbers with a binary twist

Warning : this is NOT a "hey, let's draw a cake in ASCII-art" challenge! Please keep reading ;) Some time ago it was my birthday, I'm 33 now. So there is this awkward social tradition consisting in ...
• 401
249 views

### Binary Magic Cards [closed]

There's a cool magic trick that works using the power of binary. The effect of the trick is as follows: An audience member chooses some natural number in the range of ...
• 3,723
3k views

### Encode an integer

Given positive integer n > 2. We convert it to an array as follows: If it is equal to 2 return an empty array Otherwise ...
4k views

### Fractal Cathedral

Given a positive integer n >= 1, output the first n rows of the following structure: ...
• 41.3k
2k views

### Easy binary triangle

Given as input a positive integer n>=1, output the first n rows of the following triangle: ...
1k views

### Weakened Binary Walls

Inspired by Create a binary wall Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example: ...
• 41.3k
5k views

### Create a binary wall

Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall. How does this work? Convert each number to it's ...
• 7,149
7k views

### Is the number binary-heavy?

An integer is binary-heavy if its binary representation contains more 1s than 0s while ignoring leading zeroes. For example 1 is ...
• 11.6k
4k views

### The dragon Curve sequence

The dragon curve sequence (or the regular paper folding sequence) is a binary sequence. a(n) is given by negation of the bit left of the least significant 1 of <...
• 96.5k
302 views

### I text the correct combo of ones and zeros

I recently listed to the song I'm a Textpert about texting while driving and one particular line in the song inspired this challenge. I never stoop so low as to text photos / Instead I text the ...
• 49.4k
125 views

### Reflective binary ordering

The reverse of an n-bit number is just its n binary digits in reverse order: 001010010 → 010010100 Given a number n, generate all n-bit integers ([0, 2n-1]) in an arbitrary order, with ...
• 39k
2k views

### Decrypt xor-encryption

Your task is to take an encrypted string as input, and output the string decrypted, to reveal its hidden message. The strings, both the input and output, will contain characters from this list of 64 ...
• 46.2k
5k views

### Fizz Buzz to Text

Introduction I don't particularly know where the fizz buzz trend came from. It might just be a meme or something, but it is somewhat popular. Challenge Your job today is to convert Fizz Buzz into ...
• 887
4k views

### Find a binary needle in a decimal haystack

The challenge You're given: a non-empty, unsorted list h of positive integers (the haystack) a positive integer n (the needle) Your task is to return the list of all unique decimal concatenations ...
• 188k
1k views

### Generate Hamming codes

Given a stream of bits, output the shortest possible Hamming code that encodes it. The steps to generate the Hamming code are as follows, although your submission does not necessarily have to conform ...
• 71.4k
435 views

### Eyeballing the bits

Eyeballing the binary values printed as ovals and sticks is not so easy... To help with that, you must write a function (or a program) that prints numbers in custom binary representation. So I want to ...
• 251
2k views

### Split me in half

You will be given a number x, where 0 <= x <= 2^32 - 1. You should output a list of numbers in decimal, after recursive ...
2k views

### Calculate the binary split sum of a word

Take a string, s containing printable ASCII-characters as input, and output its "binary split sum". Need an explanation? How do you get the binary split sum? We'...
• 46.2k
2k views

### Binary Puzzle Solver

Introduction Rules of the puzzle: The puzzle Binary (also known as Takuzu or Subiku) is very simple to understand, and has only a few rules: Since the name of the game is binary it's pretty obvious, ...
• 123k
811 views

### C# First 1 (right to left) in binary number

I am trying to use C# to find the index of the first 1 (right to left) in the binary representation of a number. For example, since 100 in binary is: 0b1100100 ...
2k views

### Binary Branches

Given a binary number, your task is to create a 'branch' of that number, with a depth of 2. For example, given 0 as input, you should output exactly this: ...
• 16.4k
623 views

### Convert Binary to Text [duplicate]

Your task is to write a program, which takes a binary input and converts it to plain text. For Example: 01100001 01100010 01100011 = "abc" Rules Input can come ...
• 323
2k views

### Count the number of Hamming distance sequences

The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Let P be a binary string of ...
1k views

### Count how many distance sequences are far from all others

The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Let P be a binary string of ...
3k views

### Disconnect 4 bits

Your task: given an input string, determine whether the binary representation of that string does not have 4 1s or 0s in a row, ...
• 9,369
3k views

### Write self-validating code

Write code that takes a string as input, and outputs a truthy or falsey value depending on whether or not the string follows these rules: If you stack each character on top of each other, convert to ...
• 46.2k
2k views

### Bitflip-resistant composite numbers

Sometimes, when writing a program, you need to use a prime number for some reason or other (e.g. cryptography). I assume that sometimes, you need to use a composite number, too. Sometimes, at least ...
893 views

### Smallest multiplier that reveals a factor of a semiprime

Given a semiprime N, find the smallest positive integer m such that the binary representation of one of the two factors of N can be found in the binary representation of N * m. Example Let's ...
• 188k
3k views

### Counting in binary nybbles

This challenge is to output to your terminal, window, canvas or screen the numbers zero to 10 inclusive. Each outputted number must be shown as a 4-bit wide nybble, so zero must show as ...
• 2,222
4k views

### Output numbers up to 2^n-1, "sorted"

Take a positive integer n as input, and output (some of the) decimal numbers that can be created using n bits, ordered in the following way: First list all the numbers that can be created with only ...
• 46.2k
2k views

### Primes with prime bit-counts

Task Find all the non-negative integers up to and including a given non-zero positive integer n, that are prime and the count of 1's and ...
• 1,981