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 results575 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Folding a CubeGiven a connected arrangement of six unit squares with no 2x2 block, decide whether it can be folded into a cube.Medium7DFSGeometry+2No attempts yet1s512 MBJudgeable
Hidden WordsGiven a grid of up to 10x10 letters and up to 100,000 query words of length at most 10, count how many words can be traced through adjacent, non-repeating cells.Medium7BacktrackingDFS+2No attempts yet2s512 MBJudgeable
Bin PackingGiven up to 24 item weights and a bin capacity S, find the minimum number of bins that hold all items with each bin's total weight at most S.Medium7Dynamic programmingBit manipulation+2No attempts yet4s256 MBJudgeable
Make a NumberStarting from 1, find the minimum number of +1, -1, and power operations needed to reach a target N up to 10^18.Hard8Number theoryMath+2No attempts yet2s128 MBJudgeable
Teaching LettersGiven N Antarctic words that all begin with anta and end with tica, pick K letters to maximize how many words are fully readable.Hard8Brute forceBacktracking+1No attempts yet1s128 MBJudgeable
Non-Repeating WordFind the lexicographically smallest length-N string over the first A letters that never contains K consecutive copies of any nonempty block.Hard8BacktrackingString+2No attempts yet2s128 MBJudgeable
Increasing ListReplace every '?' in a string with a digit or comma to form the lexicographically smallest strictly increasing list of positive integers with no leading zeros, or print -1 if impossible.Hard8BacktrackingGreedy+2No attempts yet2s128 MBJudgeable
CoveringTile every X cell of a grid using unrotated 6-cell A pieces and 2-cell horizontal B pieces without overlap, printing the lexicographically smallest covering or -1 if impossible.Hard8Dynamic programmingBacktracking+2No attempts yet2s128 MBJudgeable
Equal Digit CountsGiven N up to 10^18, find the smallest number at least N where every digit that appears occurs the same number of times.Hard8CombinatoricsBacktracking+2No attempts yet2s128 MBJudgeable
Minimum Resistor NetworkFind the minimum number of 1-ohm or 2-ohm resistors combined via series and parallel connections to achieve an exact resistance a/b, capped at 16 or else -1.Hard8MathRecursion+2No attempts yet2s128 MBJudgeable
Two-Pan BalanceGiven distinct weights, count and rank all balance-point arrangements on a ten-mark two-pan scale as generated integers, returning the k-th smallest or the largest if fewer exist.Hard8BacktrackingCombinatorics+2No attempts yet1s128 MBJudgeable
Bus RoutesGiven a multiset of arrival minutes within a 60-minute window, reconstruct the minimum number of arithmetic-progression bus routes (each appearing at least twice) that exactly explain the multiset.Hard8CombinatoricsGreedy+2No attempts yet2s128 MBJudgeable
Knight TourConstruct a full knight's tour on an N by N board (N up to 666) starting from a given square, using Warnsdorff-style or divide-and-conquer construction, or report impossibility.Hard8BacktrackingDivide and conquer+1No attempts yet1s128 MBJudgeable
PicnicFind the lexicographically smallest clique of exactly K students among N students given F friendship edges, or report -1 if none exists.Hard8BacktrackingGraph+1No attempts yet2s128 MBJudgeable
Magic OrbsConstruct a permutation of rooms 1..N starting at a given M so that consecutive absolute differences use each value 1..N-1 exactly once, visiting every room once.Hard8CombinatoricsMath+1No attempts yet2s128 MBJudgeable
Graph HashGiven a weighted graph with up to 30 vertices, compute the LCM over all simple paths from vertex 1 to 2 of the GCD of edge weights on each path, with results up to 1000 digits.Hard8GraphDFS+2No attempts yet2s128 MBJudgeable
Mirror RestorationReconstruct an N by M grid of empty cells and '/' mirrors so that shooting rays from all 2N+2M boundary holes matches a given exit-hole permutation.Hard8SimulationBacktracking+1No attempts yet2s128 MBJudgeable
Divisor Subsequence SeriesGiven N, repeatedly delete digits forming a proper divisor subsequence to build the longest possible chain, breaking ties lexicographically smallest.Hard8BacktrackingGreedy+2No attempts yet2s128 MBJudgeable
Gray CodeConstruct a cyclic Gray code of length M bits that includes one or two specified adjacent pairs, or report impossibility.Hard8CombinatoricsBacktracking+1No attempts yet1s128 MBJudgeable
Triangular PuzzleReconstruct a triangular 0/1 matrix from run-length block sequences given for every row and column, or report impossibility.Hard8BacktrackingCombinatorics+1No attempts yet1s128 MBJudgeable
MinesweeperGiven an N x N board whose border cells hold clue digits, place mines in the interior cells to satisfy every clue while maximizing total mines placed.Hard8BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Roman Numeral WalkFind the longest path from the grid center through empty-separated cells that spells consecutive Roman numerals starting at 1, and print the last number reached.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
The AlliancesDetermine if a grid of villages requiring exact alliance counts (with a directional twist for humans) admits a valid edge-selection satisfying all degree constraints.Hard8GraphBacktracking+1No attempts yet1s128 MBJudgeable
InsultsParse a string against a context-free grammar defining insults, then find the lexicographically next same-length valid insult or report invalid/ultimate.Hard8StringDynamic programming+2No attempts yet1s128 MBJudgeable
Japanese WritingDetermine whether each of several stroke-based hieroglyph writings is isomorphic to a reference writing, preserving stroke directions and pairwise endpoint directions among all 8 compass directions.Hard8GraphBacktracking+1No attempts yet2s128 MBJudgeable
Tournament ManipulationGiven head-to-head results for n teams (n up to 8) with a guaranteed property for team 1, construct the lexicographically smallest single-elimination bracket where team 1 becomes champion.Hard8BacktrackingGreedy+1No attempts yet1s128 MBJudgeable
ProductsFind the minimum count k of positive integers a1..ak such that the product of (ai+1) equals n times the product of ai.Hard8Number theoryMath+2No attempts yet1s128 MBJudgeable
Lord of the RingGiven all pairwise distances between bushes on a line, reconstruct the actual bush positions (the classic turnpike/beltway problem) and output the product of adjacent gaps, or report no solution.Hard8BacktrackingCombinatorics+1No attempts yet1s128 MBJudgeable
Mobile ComputingBuild every possible binary mobile from given stone weights and pick the widest one whose width is strictly less than a given room width, output as reduced fraction.Hard8RecursionBacktracking+2No attempts yet1s128 MBJudgeable
Snake CubeGiven a snake cube flattened on a 15x15 grid as 27 labelled cells, fold it back into a 3x3x3 cube and print the lexicographically smallest of all valid layer arrangements.Hard8BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Guess My WordGiven a corpus of words with distinct letters, decide for each corpus whether player A can always win the hangman-like game by secretly switching consistent words.Hard8Game theoryBacktracking+2No attempts yet2s256 MBJudgeable
Hexagon PerplexagonPlace 7 hexagon pieces in a flower so numbers match on all 12 shared edges, and report the unique valid arrangement.Hard8BacktrackingBrute force+2No attempts yet2s128 MBJudgeable
Stake Your ClaimOn an n by n board with 1 to 10 empty squares, find the current player's optimal move and final score difference under optimal play.Hard8Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
HexagramCount how many ways, up to rotation and reflection, the 12 given distinct numbers can be placed on the 12 vertices of a hexagram so all 6 lines share one sum.Hard8Brute forceBacktracking+2No attempts yet5s128 MBJudgeable
WormsGiven string rewriting rules, find the minimum number of days to grow the target worm from one cell, where each day any subset of cells splits.Hard8Dynamic programmingIntervals+1No attempts yet2s128 MBJudgeable
Triangle WarFrom a partially played Triangle War position, decide with perfect play which player ends up owning more of the 9 small triangles.Hard8Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
PipesGiven a grid of pipe tiles that may be rotated by multiples of 90 degrees, decide whether the tiles can be oriented so that every internal border edge is covered by lines on both sides or neither side.Hard8BacktrackingDFS+2No attempts yet1s128 MBJudgeable
PyramidsGiven a count of stones, find the smallest set of distinct high or low pyramids (height at least 2) that uses every stone, breaking ties by maximizing sizes lexicographically, or report impossible.Hard8Dynamic programmingGreedy+2No attempts yet5s512 MBJudgeable
Crypt KickerDecrypt each line of a substitution cipher so every word appears in a given dictionary, choosing the lexicographically smallest result, or mask the line if none exists.Hard8BacktrackingString+2No attempts yet1s128 MBJudgeable
Fill the CrosswordFill a crossword grid with a given word list so every slot holds a listed word exactly once and crossings match; also decide if no solution exists.Hard8BacktrackingTrie+2No attempts yet1s128 MBJudgeable
Su-domino-kuComplete a 9x9 Sudoku grid in which 36 dominoes cover the empty cells and every distinct digit pair appears as exactly one domino.Hard8BacktrackingDFS+2No attempts yet2s128 MBJudgeable
Top ThisGiven three red tetromino-like pieces and three blue ones, print the row-major first filled cell shape that both sets can tile inside a 6x6 grid.Hard8BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Bright BraceletArrange all octagons in a cycle so adjacent edges match in color, minimizing the total brightness at the joints.Hard8BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Stained GlassGiven up to 8 polyomino-like ASCII piece silhouettes, each flippable horizontally, decide whether translations of them exactly tile the hole silhouette.Hard8BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Crosswords InsiderGiven a list of words and a crossword grid template, decide whether each word can fill one run of empty cells and output the lexicographically smallest filled grid.Hard8BacktrackingSimulation+2No attempts yet1s128 MBJudgeable
Moving SticksGiven an arithmetic equation written in seven-segment digits, move exactly n segments so the equation becomes true, choosing the lexicographically smallest solution.Hard8Brute forceImplementation+2No attempts yet1s128 MBJudgeable
Weaker than PlannedGiven candidate plaintext words and a ciphertext message, recover the plaintext under one unknown letter-pair substitution, or report that it is not unique.Hard8BacktrackingString+2No attempts yet1s128 MBJudgeable
Captain Q's TreasureGiven a grid with at most 15 digit cells, each stating how many chests lie in its 3x3 neighborhood, find the minimum number of chests consistent with all digits.Hard8BacktrackingBrute force+2No attempts yet3s128 MBJudgeable
InfiltrationGiven an encrypted line using a one-to-one letter substitution, recover the plaintext if exactly one consistent mapping exists using a subset of twelve known words that covers all distinct cipher letters.Hard8StringHash map+2No attempts yet1s128 MBJudgeable
Polyomino PowersGiven a polyomino on a grid up to 10x10, find the smallest k in 2..5 such that the shape is tiled by k translated copies of one smaller polyomino, or report none.Hard8Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
Circle of DebtGiven three people's debts and the exact bills and coins each holds, find the minimum number of pieces that must change hands to settle all debts.Hard8Dynamic programmingBacktracking+2No attempts yet1s128 MBJudgeable
The Rotation GameGiven a 24-cell board, find the shortest sequence of the eight line-rotation moves that makes the eight center cells show the same symbol.Hard8DFSBrute force+2No attempts yet1s128 MBJudgeable
Lego Brick WallsDecide whether a rectangular wall can be tiled with given bricks of widths 1 to 3, respecting fixed bricks and the rule that joints in adjacent rows never align, given brick counts.Hard8Dynamic programmingBacktracking+1No attempts yet1s128 MBJudgeable
Runaway Time MachinesGiven a weighted undirected graph and, for each of several machines, a start and a shortest-path distance, decide whether the distinct destinations are uniquely forced.Hard8Shortest pathGraph+2No attempts yet1s128 MBJudgeable
Puzzle AssemblyGiven four n x n pieces with cut corners, rotate and mirror them to tile a (2n-1) x (2n-1) square with no gaps or overlaps, printing the lexicographically smallest result.Hard8BacktrackingImplementation+2No attempts yet0.5s64 MBJudgeable
The Bad ScientistGiven a graph of contradictions, delete at most k vertices to remove all edges and report the smallest such set size, or IMPOSSIBLE.Hard8GraphBrute force+2No attempts yet1s128 MBJudgeable
Prime SquareFind all 5x5 digit grids whose five rows, five columns and two diagonals are five-digit primes with the same given digit sum and a fixed top-left digit, printed in lexicographic order.Hard8BacktrackingNumber theory+2No attempts yet1s128 MBJudgeable
Crossing Thin IceGiven an m by n grid of ice cells, find the longest path that starts anywhere and only steps onto unbroken ice, breaking each visited cell.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Game of TilesTwo players alternately extend a path of numbered tiles on a grid with blocked cells; the player unable to move loses. Determine the winner under optimal play.Hard8GraphGame theory+2No attempts yet1s128 MBJudgeable
Light UpOn a board up to 7 by 7 with numbered barriers, find the minimum number of lamps that light every empty square, where no two lamps see each other and each numbered barrier has an exact count of adjacent lamps, or report no solution.Hard8BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
Pahom on WaterDecide whether Pahom can travel from the red pad to the violet pad and back, stepping only to strictly higher frequencies outbound and strictly lower ones inbound, with each non-red pad vanishing after he leaves it.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
Numbers GameGiven 4 to 7 integers, combine each at most once with +, -, *, or truncated integer division to reach a value as close as possible to a target, printing the smaller value on ties.Hard8BacktrackingBrute force+2No attempts yet5s128 MBJudgeable
Balanced Cow SubsetsCount how many subsets of up to 20 cows can be split into two groups with equal total milk output.Hard8BacktrackingBit manipulation+2No attempts yet1s128 MBJudgeable
Junkyu and the ApplesOn a 5x5 grid with K blocked cells (K even, up to 22), count the ways two harvesters starting at opposite corners can each tour all open cells and meet at the end.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
Winning CheckersFind the lexicographically smallest sequence of diagonal jumps by which a single king captures every opponent checker on an N x N board, or report that none exists.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
Jigsaw PuzzlesPlace every piece into an R by C grid, rotating but not flipping, so touching edges match and the outer boundary is all borders; print the lexicographically smallest assembly.Hard8BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
CheckersOn an N x N board, decide whether one king can capture every opponent checker in a single move of consecutive diagonal jumps, and print the unique landing sequence if so.Hard8DFSBacktracking+2No attempts yet1s128 MBJudgeable
Sharif Super ComputerChoose distinct positive slave heights between 0 and a top master height H so that all red cable lengths match exactly and every slave pair distance is an allowed blue length, minimizing the output sequence lexicographically.Hard8Brute forceBacktracking+2No attempts yet1s128 MBJudgeable
NurikabeSolve Nurikabe puzzles on grids up to 9x9 by coloring cells black or white so all six connectivity and counting rules hold.Hard8BacktrackingDFS+2No attempts yet1s128 MBJudgeable
Triangle PizzaCount the number of distinct connected polyiamonds with N cells, where shapes that match under rotation or translation count as one and reflections are distinct.Hard8BacktrackingImplementation+2No attempts yet1s128 MBJudgeable
HexagonPlace 19 of 27 hexagonal pieces on a 19-cell board so that the total of all 15 monochromatic row scores is as large as possible.Hard8BacktrackingBrute force+2No attempts yet1s128 MBJudgeable
ShipsGiven partial knowledge of seven non-overlapping tetromino ships on a grid, decide if all 28 ship squares can be uncovered with at most one miss against every consistent arrangement.Hard8BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Addition ChainsFor each n up to 100, find a shortest addition chain ending at n and print the lexicographically smallest among all shortest ones.Hard8DFSBacktracking+2No attempts yet1s256 MBJudgeable
Domino TilingCover a grid with pre-placed tiles and all given dominoes, then output the lexicographically smallest valid tiling and the count of other tilings.Hard8BacktrackingDynamic programming+2No attempts yet1s128 MBJudgeable
All FriendsCount the maximal cliques of an undirected graph with up to 128 vertices, reporting "Too many" when the count exceeds 1000.Hard8GraphBacktracking+2No attempts yet1s128 MBJudgeable
AgentsGiven a graph of dislikes where at most three agents touch everyone else, decide whether the vertices 3-color into at most three independent sets and output the lexicographically smallest coloring.Hard8GraphDFS+2No attempts yet1s128 MBJudgeable
OrkoGiven ten cards for player A and the rest for B, compute how many of the ten rounds A wins when both play optimally, with A leading first.Hard8Game theoryBacktracking+2No attempts yet1s128 MBJudgeable
The Game of 31Given a partly played game of 31 with four cards of each value 1 to 6, determine the winner under perfect play.Hard8Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
Conditional StatementsParse a small nested if language, then for each checkpoint decide which variable assignments can reach it and print the forced true/false variables or unreachable.Hard8SimulationImplementation+2No attempts yet10s128 MBJudgeable
Number SquareFill an N x N Latin square with 1..N given some pre-filled cells and inequalities between neighboring cells, choosing the lexicographically smallest valid board.Hard8BacktrackingImplementation+2No attempts yet1s1024 MBJudgeable
Transformation from OneStarting from 1, you may add 1 to the first or last digit for cost 1, or multiply it by 2..9 for cost 2; find the minimum cost to reach each given number, or -1.Hard8BacktrackingBFS+2No attempts yet1s1024 MBJudgeable
Blue x Red = BangGiven up to nine blue and nine red points, decide whether a simple blue polygon and a simple red polygon can be drawn with disjoint interiors and boundaries.Hard8GeometryBrute force+2No attempts yet1s128 MBJudgeable
The Bermuda TriangleGiven a regular hexagon of side s and allowed equilateral triangle sizes, decide whether the hexagon can be tiled exactly by triangles of those sizes.Hard8BacktrackingGeometry+2No attempts yet1s128 MBJudgeable
Puzzle OutGiven a dictionary and an encrypted uppercase text, recover the substitution cipher table or report no solution or multiple solutions.Hard8BacktrackingHash map+2No attempts yet1s128 MBJudgeable
Black BoxFind all 6x6 atom placements inside an 8x8 box that reproduce a set of laser entry and exit experiments, and report the layout if it is unique.Hard8SimulationBrute force+2No attempts yet2s1024 MBJudgeable
ExpressionsFor each range of digits and target, print every fully bracketed expression over the digits in order that evaluates to the target. (Note: summary must be one sentence, at most 160 chars.)Hard8BacktrackingRecursion+2No attempts yet1s128 MBJudgeable
Equilateral DominoesGiven up to 6 equilateral dominoes with pip values 1 to 6, tile a connected subset on the triangular grid to maximize shared edges between adjacent matching ends.Hard8BacktrackingGeometry+2No attempts yet15s128 MBJudgeable
BattleshipFire order over a 10x10 grid is given; place the ten standard ships without touching so the game lasts as long as possible.Hard8GreedyBacktracking+2No attempts yet2s256 MBJudgeable
Showy Self-DefenseGiven n game states, each with optional A/B moves to other states, decide if for every attacker start there is a distinct defender start that can mirror every move.Hard8GraphGame theory+2No attempts yet10s128 MBJudgeable
PartyEvery pair of students is either friends or enemies; pick a set with no enemy pair that is closed under friends, maximizing size and counting the ways.Hard8GraphUnion-find+2No attempts yet1s128 MBJudgeable
StampsDecide whether given stamps can cover every # cell of a picture up to 100 by 100 without coloring any . cell.Hard8BacktrackingBrute force+1No attempts yet1s512 MBJudgeable
Prime Factor ArrangementsGiven n, find the smallest integer k greater than 1 whose prime factors admit exactly n distinct orderings.Hard8CombinatoricsNumber theory+1No attempts yet3s256 MBJudgeable
HarvardAssign each variable of a program with nested repeats to a memory bank within capacity to minimize access and select costs.Hard8BacktrackingDynamic programming+1No attempts yet10s128 MBJudgeable
BooksortGiven a permutation of 1 to n with n at most 15, find the fewest adjacent block swaps that sort it, reporting 5 or more when the minimum exceeds 4.Hard8BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Fragment ReassemblyArrange the given text fragments so neighbors share an exact overlap and print the joined text in lines of at most 72 characters.Hard8BacktrackingString matching+1No attempts yet1s128 MBJudgeable
Intellectual PropertyDecide for each pair of 9x9 Sudoku grids whether digit relabeling, row and column band swaps, and transposition turn one into the other.Hard8BacktrackingBrute force+1No attempts yet2s256 MBJudgeable
ASCII PuzzleYou reassemble k shuffled pieces with jagged borders into the original rectangle and print the lexicographically smallest layout.Hard8BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
C(O|W|A*RD*|S)* CROSSWORD PuzzleFill a 2 to 4 by 2 to 4 grid with capital letters so each row and column matches its regex clue, and report the unique solution, none, or ambiguous.Hard8BacktrackingString matchingNo attempts yet10s128 MBJudgeable
BattleshipsCount the fleets that fit the given row and column sums on a 10x10 board, then name the smallest one or two cell reveals that leave exactly one fleet.Hard8BacktrackingBrute force+1No attempts yet10s128 MBJudgeable
Euler's ProblemGiven n, list every x with Euler phi(x) equal to n in increasing order, or report none.Hard8Number theoryBacktracking+1No attempts yet1s128 MBJudgeable