Questions tagged [bitwise]
For challenges involving bitwise commands or manipulation of numbers at the bit level
73
questions
18
votes
12
answers
2k
views
Is it a valid ARM immediate value?
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 ...
17
votes
18
answers
2k
views
XOR of independent Bernoulli variables
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 ...
1
vote
0
answers
171
views
making a binary string palindrome using xor operations [closed]
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 \$...
15
votes
3
answers
566
views
Count the number of disjoint 11 blocks
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 ...
2
votes
3
answers
308
views
Shift distance of number [closed]
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn ...
8
votes
3
answers
386
views
Smallest and largest 100-bit square with maximum Hamming weight
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 ...
8
votes
2
answers
609
views
Inverting string-based binary number in one line in Python
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 ...
4
votes
19
answers
573
views
Double bit rotation to the right [closed]
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. ...
0
votes
4
answers
131
views
Calculate the truncated log2 of some unsigned integer [duplicate]
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 ...
6
votes
3
answers
390
views
Dr. Lamport's Unfinished Business
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 ...
16
votes
6
answers
885
views
Golf this Thumb-2 Constant!
One thing that is constantly frustrating when golfing ARM Thumb-2 code is generating constants.
Since Thumb only has 16-bit and 32-bit instructions, it is impossible to encode every immediate 32-bit ...
18
votes
9
answers
1k
views
The Koszul Sign Rule
A Bit of Background
The exterior algebra is a central object in topology and physics (for the physics concept cf. fermion). The basic rule dictating the behavior of the exterior algebra is that \$yx =...
12
votes
9
answers
1k
views
Simulate D Flip-Flop
Objective
Simulate an edge-triggered D Flip-Flop.
What is D Flip-Flop?
A D flip-flop is an electronic digital device that outputs an inputted data (abbr. D) with synchronization to a clock (abbr. ...
16
votes
23
answers
2k
views
Summing a sub-square of a quarter of an infinite chessboard
Description of the problem
Imagine a quarter of an infinite chessboard, as in a square grid, extending up and right, so that you can see the lower left corner. Place a 0 in there. Now for every other ...
7
votes
13
answers
216
views
Computational Parity Party! [duplicate]
The computational parity of an integer is defined as 1 if the integer has an odd number of set bits, and 0 otherwise. (src).
Input
You will receive one nonnegative integer that you will take the ...