Skip to main content

Questions tagged [bitwise]

For challenges involving bitwise commands or manipulation of numbers at the bit level

11 votes
7 answers
739 views

This challenge is from a video game, Keep Talking And Nobody Explodes. A yes or no choice isn’t too bad. Unfortunately you have to make five of them and any of them could be your last. — from the ...
Dannyu NDos's user avatar
  • 7,381
8 votes
7 answers
950 views

The Compatibility Encoding Scheme for UTF-16: 8-Bit, also known as CESU-8, is a Unicode encoding that is not part of the Unicode standard, but mentioned in a Unicode Technical Report as a ...
Explorer09's user avatar
13 votes
17 answers
2k views

Recently I had to implement this problem in c#, and thought it would make for a good code golf. Your goal is to output the smallest unsigned data-type a 64 bit unsigned number can fit into. Input: An ...
Ezlanding's user avatar
  • 381
5 votes
9 answers
362 views

Given a binary string \$s\$ of length \$2^n\$ and a permutation \$\sigma\$ of \$\{1,\dots,n\}\$, generate the binary string \$u\$ of length \$2^n\$ which is a reordering of \$s\$ such that \$u[i^\...
Karl's user avatar
  • 871
22 votes
2 answers
2k views

The task is to find parameters that make a fast leap year check correct for the widest range of years. We assume the Proleptic Gregorian calendar, which extends the Gregorian calendar backward from ...
Falk Hüffner's user avatar
18 votes
12 answers
2k views

Exposition In this challenge, I am talking about ARM assembly language. ARM is a 32-bit RISC processor; I'll use instruction set up to architecture v6. To load a constant ("immediate") value ...
anatolyg's user avatar
  • 14.1k
17 votes
18 answers
2k views

In probability theory, a Bernoulli variable is a random variable which has a single parameter \$p\$, and is equal to 1 with probability \$p\$, and 0 with probability \$1-p\$. In this challenge, there ...
Command Master's user avatar
2 votes
0 answers
272 views

Problem You are given a binary string A of length N. You can perform the following type of operation on the string A: Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$) Change \$...
hemanth's user avatar
  • 21
15 votes
3 answers
621 views

The task is to count the number of disjoint 11 blocks in a 64-bit word, using the minimum number of straight-line instructions. That is, how many nonoverlapping ...
Falk Hüffner's user avatar
2 votes
3 answers
346 views

Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn ...
l4m2's user avatar
  • 32.5k
9 votes
3 answers
540 views

Introduction In the binary representation of a \$k-\$bit \$(k>1)\$ square number \$n^2, \$ not all bits can be \$1\$. The maximum number of \$1\$-bits (Hamming weight, \$B\$ for short) is given in ...
Hugo Pfoertner's user avatar
9 votes
2 answers
692 views

I want to read two strings on separate lines, each string the same length and containing only 0's and 1's, and determine if the first is the one's complement of the second. How succinctly can this be ...
Fixee's user avatar
  • 191
4 votes
19 answers
714 views

Given a positive integer as input, output that integer, but with its bits rotated two times to the right. Also, think of the number as a donut of bits, eg. ...
Joao-3's user avatar
  • 2,080
0 votes
4 answers
158 views

Definition Given some number, x calculate the smallest number i such that 2i≥x. This is not a duplicate of this question. It is slightly different in that an input of 16 should yield an output of 4 ...
Nigel's user avatar
  • 357
6 votes
3 answers
462 views

Introduction Dr. Leslie Lamport, of the eponymous Lamport one-time signature scheme, is getting rather old. But he can't die until his most famous algorithm gets all the kinks ironed out! In ...
JamesTheAwesomeDude's user avatar

15 30 50 per page
1
2 3 4 5 6