Questions tagged [binary]

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

Filter by
Sorted by
Tagged with
43 votes
17 answers

Generate the Temple Skyline Sequence

Consider the following process: Take some non-negative integer N. e.g. N = 571 Express it in binary with no leading zeroes. (Zero itself is the only exception, ...
Calvin's Hobbies's user avatar
34 votes
32 answers

16-bit binary grid

Given any unsigned 16 bit integer, convert its decimal form (i.e., base-10) number into a 4x4 ASCII grid of its bits, with the most-significant bit (MSB) at the top left, least-significant bit (LSB) ...
type_outcast's user avatar
9 votes
5 answers

Print a table of numbers in decimal and 2**i bases

Computers live by binary. All programmers know binary. But the 2**x bases are often neglected as non-practical, while they have beautiful relations to binary. To ...
Caridorc's user avatar
  • 2,334
0 votes
2 answers

Generate ordered binary combinations without repetitions [closed]

Challenge Write the shortest program that receives two signed integers n and i and for each ...
fpg1503's user avatar
  • 330
17 votes
3 answers

Toggle, Print, Repeat

This challenge is loosely inspired by the unimplemented esolang Pada. Consider an array of 8 bits, all initialised to zero. We'll introduce a very minimalistic instruction set to print arbitrary ...
Martin Ender's user avatar
19 votes
8 answers

Binary Images of Triangle Counts

My challenges tend to be a little bit hard and unattractive. So here something easy and fun. Alcuin's sequence Alcuin's sequence A(n) is defined by counting ...
Jakube's user avatar
  • 21.9k
7 votes
3 answers

Nameless to Brainf**k converter

This is inspired by the Brainf*** to tinyBF converter challenge. Brainf**k (which will be henceforth referred to as BF) is a well-known estoric programming language, so I won't go over it too much ...
kirbyfan64sos's user avatar
28 votes
26 answers

Find the next 1-sparse binary number

A positive integer N is K-sparse if there are at least K 0s between any two consecutive 1s in its binary representation. So, the number 1010101 is 1-sparse whereas 101101 is not. Your task is to ...
articuno's user avatar
  • 381
32 votes
77 answers

Count the number of ones in an unsigned 16-bit integer

Write some statement(s) which will count the number of ones in an unsigned sixteen-bit integer. For example, if the input is 1337, then the result is ...
ayane_m's user avatar
  • 1,019
11 votes
11 answers

Binary encryption

This is based on xkcd #153. Make a program or named function which takes 2 parameters, each of which is a string or a list or array of bytes or characters. The second parameter will only contain ...
user avatar
26 votes
65 answers

String to Binary

This is a code golf challenge. Just like the title says, write a program to covert a string of ascii characters into binary. For example: "Hello World!" should ...
ericmarkmartin's user avatar
18 votes
22 answers

Find the substring with the most 1's in a sequence

Introduction I want to find the substring with the most 1's in a sequence of 0's and 1's. ...
hmatt1's user avatar
  • 3,456
21 votes
9 answers

Convert numbers to binary... but you're allowed to use twos as well

Based on the "binary, but with twos" notation mentioned in this numberphile video, write a function that takes a single number as input and outputs all variations of that number in a "...
Alconja's user avatar
  • 657
6 votes
7 answers

Find the simplest value between two values

Goal Your goal is to find the simplest value in an open interval. In other words, given two values a,b with a<b, output the ...
xnor's user avatar
  • 144k
35 votes
69 answers

Convert a string of binary characters to the ASCII equivalents

Take a string of binary characters separated by a space, and convert it to an ASCII string. For example... ...
James Williams's user avatar
11 votes
16 answers

Give me the Gray Code list of bit width n

The Gray Code is a sequence of binary numbers of bitwidth n where successive numbers differ only in one bit (see example output). Reference Example input: ...
ToonAlfrink's user avatar
  • 1,276
0 votes
2 answers

Make a regex that matches certain binary numbers [closed]

Your task is to create a regular expression that matches most binary numbers with an even number of 0s and an odd number of 1s (...
The Guy with The Hat's user avatar
7 votes
2 answers

math with bitwise operators

objective write a program that can perform addition, subtraction, multiplication, and division, using only bit-wise operators, by bit-wise operators i mean the equivalent of JavaScript ...
Math chiller's user avatar
-1 votes
5 answers

change two bits by using only bitwise operations [closed]

try to write shortest possible variant of logic which converts binary input by this table: 00 -> 00 01 -> 10 10 -> 01 11 -> 11 You can use only ...
neworld's user avatar
  • 117
15 votes
3 answers

Bitwise Operators in Brainfuck

Your task is to create one brainfuck program for each of the following binary operators. Each program should take one or two 8-bit numbers (A and B) from input and calculate the specified operation: <...
captncraig's user avatar
  • 4,633
7 votes
4 answers

Convert from binary to unary in 7x7 Manufactoria

In the game manufactoria, take in a binary number and output that number of red pieces. The catch? The board-size is only 7x7: Here's the manufactoria code for the problem:
dspyz's user avatar
  • 935
5 votes
7 answers

Generating Binary shapes [closed]

How could we generate shapes or images using binary? I got to messing around trying to create something that looked matrix like and got to thinking, wouldn't a great CodeGolf be to see who can make ...
Event_Horizon's user avatar
6 votes
3 answers

Implementing Binary Arithmetic

Given two binary numbers (strings containing 0s and 1s), perform operations on them, with one problem: You must keep them in binary. That means no going ...
beary605's user avatar
  • 4,302
19 votes
19 answers

Calculate hamming weight with low hamming weight

Create a program that computes the hamming weight of a string. Winner is the program with the lowest hamming weight. Rules: Hamming weight for an ASCII character is defined as the total number of ...
Polynomial's user avatar
  • 4,506
2 votes
11 answers

compute number of 1 bits in a binary representation of a number

The goal is to write a program that returns number of 1 bits in a given number. Examples 5 -> 2 1254 -> 6 56465 -> 8 Winner The winning ...
Ali1S232's user avatar
  • 425
16 votes
12 answers

Convert from binary to negabinary

Given a binary integer inclusively between 0 and 1111111111111111 (i.e. a 16-bit unsigned integer) as input, output the same ...
Peter Olson's user avatar
  • 7,712
15 votes
50 answers

Print the amount of ones in a binary number without using bitwise operators

Description Given a number, print the amount of 1s it has in binary representation. Input A number >= 0 in base 10 that ...
pimvdb's user avatar
  • 859
1 vote
13 answers

position of the only 1 in a number in binary format [closed]

Every number of the form 2i (where i is a non-negative integer) has a single 1 in its binary representation. Given such a number, output the 1-based position of the ...
mohammad shamsi's user avatar
14 votes
9 answers

Manchester encode a data stream

Manchester coding is a telecom protocol used in radio communications that guarantees bit transitions at a regular interval so a receiver can recover the clock rate from the data itself. It doubles the ...
mrmekon's user avatar
  • 313
9 votes
2 answers

Floating point addition, without floats!

Your task is to write a program, in any language, that adds two floating point numbers together WITHOUT using any fractional or floating point maths. Integer maths is allowed. Format The format for ...
Hannesh's user avatar
  • 1,225
21 votes
36 answers

Binary representation of a number is palindrome or not?

Write a full program to find whether the binary representation of a number is palindrome or not? Sample Input 5 Sample Output YES Print ...
fR0DDY's user avatar
  • 4,569
6 votes
1 answer

Nokia mystery puzzle [closed]

A friend sent me this puzzle. I'm pretty sure solving it will require some programming. Can anyone crack it? The original is here in case of encoding issues in the past below. ...
moinudin's user avatar
  • 12.5k

1 2 3 4