Questions tagged [binary]

Binary is the base 2 number system. Use this tag for challenges involving base 2.

154 questions
107 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 ...
1k 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 ...
4k 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 ...
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 ...
443 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 ...
371 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 ...
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 ...
1k 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'...
726 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, ...
558 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 ...
1k 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: ...
485 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 ...
948 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 ...
951 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, ...
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 ...
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 ...
856 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 ...
2k 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 ...
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 ...
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 ...
4k views

Bit run rundown

Given an integer n > 0, output the length of the longest contiguous sequence of 0 or 1 in ...
2k views

Digital Hardness of Integers

To find the digital hardness of an integer, take its binary representation, and count the number of times both a leading and trailing 1 can be removed until it ...
4k views

What is the reverse (binary) bit number?

So you are given a POSITIVE base 10 (decimal) number. Your job is to reverse the binary digits and return that base 10 number. Examples: ...
4k views

A bit, a nibble or byte?

Inspired by this challenge Given an integer in the range 0 <= n < 2**64, output the minimum sized container it can fit in out of bit: 1 nibble: 4 byte: 8 ...
7k views

In how many bits do I fit

For any positive 32-bit integer (1 ≤ n ≤ 0xFFFFFFFF) output the number of bits needed to represent that integer. Test cases ...
729 views

Every prime bit must alternate

A program is bit primed if bits in prime positions must alternate between zero and one, starting with one. For example, this is a template for a bit primed program with [0..47] bits. ...
719 views

Sloping Binary Numbers

Given an integer n, output the first n sloping binary numbers, either 0- or 1-indexed. They are called this because of how they ...
1k views

The Baum-Sweet Sequence

The Baum-Sweet Sequence (A086747 with a Twist) Take in a positive integer n and print the integers from 1 to n for which the Baum-Sweet sequence returns true. The ...
6k views

Binary to decimal converter

Binary to decimal converter As far as I can see, we don't have a simple binary to decimal conversion challenge. Write a program or function that takes a positive binary integer and outputs its ...
3k views

Complex Binary Numbers

Let's create a simple, surjective mapping from positive integers to Gaussian integers, which are complex numbers where the real and imaginary parts are integers. Given a positive integer, for example ...
884 views

Primenary Strings

A Primenary (binary-prime) string is one which, when written as a binary grid, every row and column has a prime total. That's quite a vague explanation, so let's break it down with a worked example.....
669 views

Binary Convolution

A binary convolution is described by a number M, and is applied to a number N. For each bit in the binary representation of <...
2k views

Binary Countdown Length

inspired by Count down from infinity Given a non-negative integer N, output the number of repetitions of the following steps it takes to reach 0: Convert ...
842 views

Ordered list of binary sequences of multiple dimensions

Given a positive integer n, output the 2^n binary sequences of length n sorted in the ...
190 views

Chained Binary Operations

Chained Binary Operations Here's a challenge involving truth tables and binary operations. For this specific challenge, your task is to use the following table of operations: To create a function ...
14k views

Where's the 0xBEEF?

This challenge was inspired by this Wendy's commercial from 1984. Illustration by T S Rogers Your task is to find a hexadecimal 0xBEEF on a binary bun. The 'beef' consists of the following pattern: ...
870 views

Super Folding Numbers

We have already defined a folding number here. But now we are going to define a Super Folding Number. A Super Folding number is a number that if folded enough times it will eventually reach one less ...
3k views

Folding Numbers

Given a number determine if it is a folding number. A folding number is a number such that if you take it binary representation and "fold" it in half, That is take the result of XNOR multiplication ...
4k views

Incrementing Gray Codes

Introduction A Gray Code is an alternative to binary representation in which a number is incremented by toggling only one bit, rather than a variable amount of bits. Here are some gray codes along ...
13k views

i love yOu i lOve you i love yOu!

XKCD #99, with the title "Binary Heart" shows a simple image of ones and zeros, with some digits colored red. The red heart is visible to the naked eye, but the message hidden in the binary sequence ...
843 views

String and ASCII [duplicate]

The Challenge Given a non-empty string containing only lowercase or uppercase letters and no spaces: Sum up the ASCII values for each character instance in the input string. The sum will be ...
2k views

Telegraphy Golf: Decode Baudot Code

Background In 1870 Émile Baudot invented Baudot Code, a fixed-length character encoding for telegraphy. He designed the code to be entered from a manual keyboard with just five keys; two operated ...
1k views

All Binary Combinations to Decimal

Disclaimer This question is not a duplicate of this question. I'm not counting specific digits, as we already have those set in the initial parameters. This question is focusing on the decimal ...
1k views

Given an integer, compute its Levenshtein code

Disclaimer: Levenshtein coding is completely unrelated to the Levenshtein edit distance metric. <Insert long story about why Levenshtein codes need to be calculated here.> The code Levenshtein ...
3k views

Only Even Bytes

The scenario Lately you have been noticing some strange behavior with your favorite text editor. At first it seemed that it was ignoring random characters in your code when writing to disk. After a ...
323 views

Given a truth table, output a Stackylogic program that satisfies it

Stackylogic is a programming language I made up in a previous challenge: Run Stackylogic. Read that post for full details and examples, but here is how it works paraphrased: Stackylogic takes ...
2k views

Run Stackylogic

Stackylogic is a logic-based programming language I made up that take in 0's and 1's for input and outputs a single ...