Problems

Pick a problem and write your solution in the built-in editor. The judge runs it against real test cases while you watch, and the wider archive is open to read whenever you like.

Total results905 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Morton NumbersRead integers x and y and print their Morton number, built by interleaving the bits of x and y.Easy1Bit manipulationNo attempts yet2s512 MBJudgeable
Gray codeConvert an n-bit binary string to its standard Gray code by copying the first bit and adding each adjacent pair of bits without carry.Easy1Bit manipulationStringNo attempts yet1s128 MBJudgeable
Binary ConversionPrint the binary representation of the given natural number N with no leading zeros.Easy1Bit manipulationNo attempts yet1s256 MBJudgeable
Power of TwoPrint 1 if the given natural number N is a power of two and 0 otherwise.Easy1Bit manipulationNo attempts yet2s512 MBJudgeable
George BooleRead one boolean operation in the form true AND false and print its result.Easy1ImplementationString+2No attempts yet2s512 MBJudgeable
Java2016Given a target constant c, print 20 fixed macro definitions and then build one expression by appending a macro for each set bit of c.Easy1ImplementationSimulation+2No attempts yet2s512 MBJudgeable
Binary NumberFor each given integer, output the positions of all bits set to 1 in its binary representation, from least to most significant.Easy2Bit manipulationImplementationNo attempts yet1s128 MBJudgeable
ElectrificationGiven switch-to-lamp toggle mappings and a sequence of switch flips, compute and print the final on/off state of each lamp using parity counting.Easy2SimulationBit manipulationNo attempts yet2s256 MBJudgeable
Explicit FormulaGiven 10 binary inputs, evaluate a fixed XOR-of-ORs boolean formula (equivalently just count pairs/triplets with at least one 1 and check parity) and output the result.Easy2Bit manipulationImplementation+1No attempts yet3s256 MBJudgeable
ParityRead bit strings whose last bit is missing plus a parity letter, and append the 0 or 1 that makes the parity match.Easy2StringBit manipulation+1No attempts yet1s128 MBJudgeable
Error DetectionFor each 16-bit value and its transmitted check bit, decide whether the check bit matches the parity of 1-bits in the value.Easy2Bit manipulationImplementationNo attempts yet1s128 MBJudgeable
Which WayFor each positive integer, convert it to binary and print left, straight, or right depending on whether it has more 0s, equal 0s and 1s, or more 1s.Easy2Bit manipulationImplementation+1No attempts yet1s128 MBJudgeable
Integer FlippingReverse the order of the 32 bits of each given unsigned integer and print the resulting value, stopping at -1.Easy2Bit manipulationNo attempts yet1s128 MBJudgeable
Reverse the Binary DigitsRead N, write it in binary without leading zeros, reverse the digits, and print the reversed string as a decimal number.Easy2Bit manipulationMathNo attempts yet1s256 MBJudgeable
DistributionYou split the integers from 0 to 2^N - 1 into 2^K boxes of equal size with equal total popcount by pairing each x with its bitwise complement.Easy2Bit manipulationMath+1No attempts yet1s512 MBJudgeable
Identifying Map TilesConvert a map tile quadkey into its zoom level and x and y coordinates.Easy2Bit manipulationStringNo attempts yet1s256 MBJudgeable
#include <Google I/O.h>Decode each block of eight I and O letters as one ASCII byte and print the message for every test case.Easy2ImplementationString+1No attempts yet5s512 MBJudgeable
New Lottery Game (Small)Count pairs (a, b) with a below A and b below B whose bitwise AND is below K.Easy2Brute forceBit manipulationNo attempts yet5s512 MBJudgeable
Odd Man OutGiven an odd-length list of invitation codes where every value appears twice except one, find the value that appears once.Easy2Bit manipulationArray+1No attempts yet5s512 MBJudgeable
Bitwise Operations on Binary NumbersGiven two equal-length binary strings, output their bitwise AND, OR, XOR, and the complemented forms of each, keeping length and leading zeros.Easy2StringBit manipulation+1No attempts yet2s512 MBJudgeable
XORXORXORXOR the value B into A exactly C times and print the result.Easy2Bit manipulationMathNo attempts yet0.2s512 MBJudgeable
XORChicGiven an XOR-encrypted string whose first 8 characters decode to "CHICKENS", recover the key and output the original string.Easy2ImplementationBit manipulation+2No attempts yet1s256 MBJudgeable
ZGiven N and coordinates (r,c) in a 2^N x 2^N grid, compute the visit order index of that cell under recursive Z-order (Morton order) traversal.Easy3Divide and conquerRecursion+1No attempts yet0.5s512 MBJudgeable
Binary to Octal ConversionConvert a binary number with up to 1,000,000 digits into its octal representation.Easy3Bit manipulationMath+2No attempts yet1s128 MBJudgeable
Guitar ConcertGiven up to 10 guitars each covering a subset of up to 50 songs, find the minimum number of guitars needed to play the maximum possible number of songs.Easy3Bit manipulationBrute force+1No attempts yet2s128 MBJudgeable
IP Network AddressGiven a list of IPv4 addresses, compute the smallest common network address and its mask that covers them all using bitwise operations.Easy3Bit manipulationImplementationNo attempts yet2s128 MBJudgeable
Binary ClockConvert a given HH:MM:SS time into two 18-bit binary clock representations, read column-major-mixed 3-column and row-major 3-row layouts.Easy3Bit manipulationImplementation+1No attempts yet1s128 MBJudgeable
Chocolate LunchGiven K, find the smallest power-of-two chocolate bar size and the minimum number of halving splits needed to obtain exactly K unit pieces.Easy3Bit manipulationMath+1No attempts yet1s128 MBJudgeable
Binary EncodingGiven m, output the truncated binary code for each integer from 0 to m-1 following the standard truncated binary encoding rules.Easy3Bit manipulationImplementation+1No attempts yet1s128 MBJudgeable
Subset SumGiven up to 20 bag sizes and a target n, pick each bag at most once to reach at least n with the smallest possible total.Easy3Brute forceBit manipulation+1No attempts yet1s128 MBJudgeable
The Elf's SwordFor each input n, find the smallest k such that the digits 0 through 9 all appear across the multiples n, 2n, ..., kn.Easy3ImplementationSimulation+2No attempts yet1s128 MBJudgeable
SteganographyDecode hidden bits from odd/even runs of spaces in a text and decode five-bit groups into characters.Easy3StringBit manipulation+1No attempts yet1s128 MBJudgeable
Really Good CompressionGiven N distinct 1000-bit files, decide whether each can be compressed to at most b bits.Easy3MathCombinatorics+2No attempts yet1s128 MBJudgeable
Coded CommunicationGiven n binary strings of length b and a received string r, find the minimum Hamming distance from r to any of the n strings.Easy3StringBrute force+2No attempts yet1s128 MBJudgeable
FingerprintsFor each of K query 5x5 bitmaps, find the database bitmap with the smallest Hamming distance and print all tied indices in increasing order.Easy3ArrayBit manipulation+2No attempts yet1s128 MBJudgeable
Parity BitSplit each line into 8-bit blocks, check whether the parity bit matches the parity of the first 7 bits, and count the mismatches.Easy3ImplementationString+2No attempts yet1s128 MBJudgeable
Elias Omega CodingFor each positive integer until a terminating 0, output its Elias omega code, built by recursively prepending the code of the bit length.Easy3Bit manipulationRecursion+2No attempts yet1s128 MBJudgeable
17 TimesGiven a binary number N of up to 1000 digits, print N times 17 in binary.Easy3StringMath+2No attempts yet1s128 MBJudgeable
The Rock GamePrint the reflected binary Gray code cycle for N bits as 2^N + 1 lines, each line showing X for covered holes and O for uncovered ones.Easy3Bit manipulationMath+2No attempts yet1s128 MBJudgeable
S-TreesGiven an S-tree's variable ordering and terminal labels, evaluate the Boolean function for each supplied variable assignment.Easy3TreeSimulation+1No attempts yet1s128 MBJudgeable
Polynomial Remainder OperationMultiply two binary polynomials over GF(2) and print the remainder modulo a third polynomial, all given as bit strings.Easy3MathBit manipulation+1No attempts yet1s128 MBJudgeable
Subdivision of KingdomSplit n towns (n even, n <= 26) into two halves of equal size so that the number of roads crossing between the halves is minimized.Easy3Brute forceBit manipulation+1No attempts yet1s128 MBJudgeable
Can You Exponentiate?Given a and b up to 1e9, print the last decimal digit of a^b.Easy3MathNumber theory+1No attempts yet1s128 MBJudgeable
Coin GameThe program flips full rows, columns, or diagonals of a 3 by 3 coin grid to make all coins match in the fewest moves, or reports -1.Easy3Brute forceBit manipulationNo attempts yet1s128 MBJudgeable
Gold RushSplit a bar of weight 2 to the n into halves with the fewest cuts so two shares of weights a and b can be formed.Easy3Bit manipulationMathNo attempts yet1s256 MBJudgeable
Spokes WheelFind the fewest left or right rotations that turn the first 32-spoke binary pattern into the second, or report that it is impossible.Easy3Bit manipulationBrute forceNo attempts yet1s256 MBJudgeable
Yet Satisfiability AgainDecide whether a CNF formula over at most 20 variables and 100 clauses has an assignment that satisfies every clause.Easy3Brute forceBit manipulationNo attempts yet1s256 MBJudgeable
XOR RangeCompute the XOR of all integers from S to F for each of up to 1000 test cases.Easy3Bit manipulationMathNo attempts yet1s256 MBJudgeable
BASE64 EncodingEncode the given alphanumeric string into BASE64 by regrouping its bytes into 6-bit values with '=' padding.Easy3Bit manipulationString+1No attempts yet1s256 MBJudgeable
BASE64 DecodingDecode a Base64 string using the standard alphabet and padding back into the original alphanumeric text.Easy3ImplementationString+1No attempts yet1s256 MBJudgeable
Base32 EncodingConvert the input string to bytes and print its Base32 encoding with the standard alphabet and padding.Easy3Bit manipulationImplementation+1No attempts yet1s256 MBJudgeable
BASE32 DecodingPrint the original string S from its given Base32 encoding with padding.Easy3Bit manipulationString+1No attempts yet1s256 MBJudgeable
Numbers on a TreeGiven the height H and an L/R path from the root, compute the label of the reached node under bottom-up right-to-left numbering.Easy3MathBit manipulationNo attempts yet1s256 MBJudgeable
2-SAT SatisfiabilityDecide whether N boolean variables admit an assignment satisfying all M two-literal clauses.Easy3Brute forceBit manipulationNo attempts yet1s256 MBJudgeable
Recruiting TeammatesPick the fewest of up to 10 students whose solvable problem sets cover all N problems, or print -1 when coverage is impossible.Easy3Brute forceBit manipulationNo attempts yet2s256 MBJudgeable
Jumbled CommunicationRecover each original byte x from the scrambled value x xor (x shifted left by one).Easy3Bit manipulationBrute forceNo attempts yet5s256 MBJudgeable
SetMaintain a set of integers 1 to 20 under add, remove, toggle, check, all, and empty, and print each check result.Easy3Bit manipulationImplementationNo attempts yet1.5s4 MBJudgeable
Snapper Chain (Small)Decide whether N chained toggle switches all turn on after K snaps, which lights the bulb.Easy3Bit manipulationSimulationNo attempts yet5s512 MBJudgeable
Lunch is not the problem right nowConvert between an IPv8 address (eight octets) and the 64-bit unsigned integer formed by concatenating their bytes.Easy3Bit manipulationImplementation+2No attempts yet1s128 MBJudgeable
Largest Common Vertex on a Rooted TreeFor two nodes in a complete binary tree numbered heap-style, find the deepest common ancestor k and print 10k.Easy3TreeMath+1No attempts yet2s512 MBJudgeable
Hot Air BallooningEach trainee's flight record is an integer whose digits are the balloon types flown; count how many distinct sets of digits appear.Easy3Hash mapBit manipulation+2No attempts yet2s512 MBJudgeable
Binary String OrderingPrint all 2^N binary strings of length N in the order given by the binary reflected Gray code formula i XOR floor(i/2).Easy3Bit manipulationMath+1No attempts yet1s64 MBJudgeable
Building a timetableFor each student, count the courses whose every meeting period lies among that student's free periods.Easy3Bit manipulationBrute force+1No attempts yet1s128 MBJudgeable
Calculate!Given A, B and a huge count C, find the value of A after XORing B into it C times.Easy3Bit manipulationMath+1No attempts yet1s256 MBJudgeable
Nemmo Nemmo (Easy)Count subsets of cells of an N by M grid, with N*M at most 25, that contain no full 2 by 2 square of chosen cells.Easy3Brute forceBit manipulation+2No attempts yet1s512 MBJudgeable
Falling ApartGiven up to 15 positive integers, two players alternately take one piece; find the final sums under optimal play.Easy3Dynamic programmingGame theory+1No attempts yet2s512 MBJudgeable
Xayahh-Rakann at Moloco (Easy)Given n jars and inseparable pairs, decide if exactly k jars can be kept so that no inseparable pair is split across the two groups.Easy3Brute forceGraph+1No attempts yet2s512 MBJudgeable
Yet Another No-Solve Prevention Problem!!For each of Q queries, decide whether the given number a is a power of two, printing 1 for yes and 0 for no.Easy3Bit manipulationMath+2No attempts yet2s512 MBJudgeable
Potato SacksGiven ten potato weights and a capacity C, decide whether some subset of the potatoes sums to exactly C and print YES or NO.Easy3Dynamic programmingBit manipulation+1No attempts yet2s512 MBJudgeable
Sam-Sam-Han Number 2Decide whether N can be written as a sum of distinct powers of 3, with at least one term, then print YES or NO.Easy3MathNumber theory+2No attempts yet1s256 MBJudgeable
Thue-Morse StringFind the character at position k in the Thue-Morse sequence, where k can be as large as 10^18.Easy3Bit manipulationMath+1No attempts yet1s256 MBJudgeable
Inverting bits (Easy)Write a program in a tiny 26-register 8-bit assembly language that reads 7 bits and outputs their complements, using the not instruction at most once.Easy3Bit manipulationImplementationNo attempts yet1s512 MBJudgeable
StickSimulate repeatedly halving and discarding pieces of a 64 cm stick until the remaining pieces sum to X, then count how many pieces are glued together.Medium4Bit manipulationSimulation+1No attempts yet2s128 MBJudgeable
Sums of Powers of ThreeGiven N, find the Nth smallest positive integer that is a sum of distinct powers of three, using a base-2 to base-3 digit mapping.Medium4MathBit manipulation+1No attempts yet2s128 MBJudgeable
PasswordGiven integer A, find the nearest smaller and nearest larger integers with the same popcount as A, using bit manipulation, or print 0 if none exists.Medium4Bit manipulationMath+1No attempts yet1s128 MBJudgeable
Decoding EDSAC DataDecode an EDSAC instruction (character opcode, address, word/double-word flag) into the fixed-point two's-complement decimal number its 17-bit binary pattern represents.Medium4Bit manipulationImplementation+1No attempts yet1s128 MBJudgeable
FaxImplement run-length encoding with specific bit-packed run and literal prefix formats, splitting long runs and literal blocks according to size limits.Medium4SimulationString+2No attempts yet1s128 MBJudgeable
Planet X3Given up to a million numbers, compute the sum over all pairs of the XOR of their values by counting set bits per bit position.Medium4Bit manipulationMath+1No attempts yet1s192 MBJudgeable
4 and 7Given K, output the K-th smallest positive integer whose digits are only 4 or 7, using a binary-representation-like construction.Medium4MathBit manipulation+1No attempts yet1s128 MBJudgeable
Access Control ListsParse an ordered ACL of allow/deny IP network rules and, for each query IP, output whether the first matching rule grants or denies access.Medium4Bit manipulationString+2No attempts yet3s256 MBJudgeable
Important WiresParse boolean formulas over up to 11 wires and count distinct output tuples across all wire assignments by brute-force enumeration.Medium4StringBit manipulation+1No attempts yet3s256 MBJudgeable
JohnDetermine the winner of a Nim-like misère game where players remove same-colored candies from piles and taking the last candy loses.Medium4Game theoryBit manipulation+1No attempts yet1s128 MBJudgeable
PseudoprimeFor each pair p and a, decide whether p is composite and satisfies a^p mod p == a, printing yes or no.Medium4MathNumber theory+2No attempts yet1s128 MBJudgeable
DuLLGiven program sizes, DLL sizes, and a sequence of program start and exit events, find the peak memory use including loaded DLLs.Medium4SimulationBit manipulation+1No attempts yet1s128 MBJudgeable
Persistent BitsStarting from a seed S, repeatedly apply (A*X+B) mod C and report, for each of the 16 bit positions, whether it is always 1, always 0, or varies.Medium4Bit manipulationSimulation+1No attempts yet1s128 MBJudgeable
Maximize the AccelerationGiven N parts that each add force and mass, choose the subset maximizing total force divided by total mass, breaking ties by smaller mass.Medium4Brute forceBit manipulation+2No attempts yet1s128 MBJudgeable
Bookshelf 2Given up to 20 cow heights and a target bookshelf height B, find the minimum amount by which some subset's total height exceeds or equals B.Medium4Brute forceBit manipulation+2No attempts yet1s128 MBJudgeable
The Eating PuzzleGiven up to 21 bucket sizes and a calorie limit, choose a subset with the largest sum that does not exceed the limit.Medium4Brute forceBit manipulation+2No attempts yet1s128 MBJudgeable
Microprocessor SimulationSimulate a 4-bit microprocessor from a 256-word hex memory dump and print the final memory state when the stop instruction runs.Medium4SimulationImplementation+2No attempts yet1s128 MBJudgeable
Guido van Rossum Built Python Out of Christmas BoredomSimulate a tiny 8-bit von Neumann machine with 32 bytes of memory until it halts, then print the accumulator as 8-bit binary.Medium4SimulationBit manipulation+2No attempts yet1s128 MBJudgeable
Quad TreeParse an XBM hex bitmap, then recursively encode it as a quad tree: uniform squares become B or W, mixed ones become Q followed by four sub-squares.Medium4Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
Decoding TaskGiven an encrypted message and the same message with a space prepended, recover the shared XOR key bytes.Medium4Bit manipulationImplementationNo attempts yet2s128 MBJudgeable
MegavirusGiven k and n viruses from generation k in a binary tree, find the deepest generation whose node is an ancestor of all given viruses.Medium4TreeBit manipulation+2No attempts yet1s128 MBJudgeable
PoliticiansSplit up to 18 people with rivalry pairs into two groups with no rival trio in either group and maximize the first group.Medium4Brute forceBit manipulation+1No attempts yet1s128 MBJudgeable
FontCount the subsets of the given words whose letters together cover all 26 lowercase letters.Medium4Brute forceBit manipulationNo attempts yet1s256 MBJudgeable
TicketsPrint the K-th n-bit string in reflective Gray code order for the given n and K.Medium4Bit manipulationRecursionNo attempts yet1s64 MBJudgeable
ShipuraEvaluate expressions that combine floor division by powers of two with squaring modulo 1,000,000,007 and nested brackets.Medium4StackRecursion+1No attempts yet8s512 MBJudgeable
XOR triplets 2Pick the largest block of consecutive integers from 1 to N with no three distinct elements xoring to zero, breaking ties by smallest start.Medium4Brute forceBit manipulationNo attempts yet5s256 MBJudgeable
MD5Read a short alphanumeric string and print its MD5 hash as 32 lowercase hex digits.Medium4ImplementationBit manipulationNo attempts yet1s256 MBJudgeable
SHA-1Given an alphanumeric string of length 1 to 50, print its SHA-1 hash as 40 lowercase hex digits.Medium4ImplementationSimulation+1No attempts yet1s256 MBJudgeable