brain
tamnd's digital brain — notes, problems, research
43815 notes
Let $d \ge 3$ be fixed.
Working
The magician’s trick reduces the task of identifying a hidden number between 1 and 100 into answering a fixed sequence of seven yes or no questions.
We are given a set of points on the integer coordinate plane, and we need to count how many distinct triples of these points form a right-angled triangle.
We are given a collection of car brands, where each brand has a fixed stock count and a fixed price per car. There are no dynamics in pricing or inventory per day other than cars being removed once bought.
We are given a small set of points on the plane, each with integer coordinates, and we need to count how many distinct triples of these points form a right triangle.
We start with a collection of existing “deliciousness values” for pig’s trotter rice dishes. These values form an array, and once sorted, we define the instability of the menu as the largest gap between consecutive values in that sorted order.
We are given several test cases. Each test case describes a set of points placed on a line. Every point has a coordinate and an additional value attached to it. We are required to construct a route that starts at point 1, ends at point n, and visits every point exactly once.
We are given several test cases, each containing a permutation of the numbers from 0 to n − 1. For any contiguous segment of this permutation, we look at the smallest non-negative integer that does not appear inside that segment, which is the mex of the segment.
We are given a collection of intervals, each interval being a segment on the number line defined by two integers $xi le yi$.
We are given a collection of strings indexed from 1 to n. These strings form a fixed ordered book, but they are not truly static because individual characters inside any string can be modified during the process. Alongside these strings, we process a sequence of operations.
We are given four axis-aligned rectangles for each test case. Each rectangle can be rotated, meaning we are free to swap its sides.
We are given a list of constituencies, each described only by a single integer representing how many votes it contains.
We are given a fixed pattern string that is formed by repeating the block "xtu" exactly n times. So the full string p has length 3n and consists of a very rigid periodic structure: every three characters are always x, then t, then u.
We start with two numbers, x and y. Each operation allows us to “pump” one of them: if we choose the first operation, x grows multiplicatively by a factor k and y gets a fixed additive boost d. If we choose the second operation, roles are reversed.
We are given an array of integers for each test case, and we are allowed to select several intervals that do not overlap. Each chosen interval contributes its sum to a global total, and we also count how many intervals we selected.
We are given an array for each test case and we need to count how many subarrays satisfy a specific parity condition: inside the chosen subarray, at least one value appears an odd number of times.
We are given two circular arrays representing pizzas, each of length $n$. Each position may contain a single topping value or be empty. The key rule is that a topping only contributes to the final score if, after combining the two pizzas, it is the only topping at its position.
We are given a string made of lowercase letters, which we can think of as a row of musical samples laid out on a disk. Any contiguous segment of this string is a candidate “clip”.
Bob has a collection of numbered records from 1 to n. Over the next n days, he listens to some subset of these records each day. A record is considered new on a given day if Bob has never listened to it on any earlier day.
We are given a collection of songs, where each song has two properties: a storage cost measured in bytes, derived from the length of its title, and a reward value. Amber has a digital vinyl with a fixed capacity in bytes.
We are given an array of numbers and a transformation that repeatedly replaces the array with its prefix product version. One application of the transformation takes an array and turns each position into the product of everything up to that index.
We are given a directed structure over $n$ labeled positions, where each position $i$ points to exactly one next position $bi$. This defines a functional graph: every node has outdegree 1, so the graph decomposes into directed cycles with trees feeding into those cycles.
The grid represents a store where each cell has a non-negative value. George starts in the bottom-right corner and wants to reach the top-left corner. He can only move one step at a time either upward or leftward, so every valid route is a monotone path on the grid.
We are given ten points in the plane, each supposed to lie on the boundary of a hidden object. The object is guaranteed to be exactly one of two types: either a vinyl record, whose boundary is a circle, or a cassette tape, whose boundary is an axis-aligned rectangle.
We are given the first few values of a sequence $f(1), f(2), dots, f(n)$, and the sequence is defined recursively in a way that depends multiplicatively on all previous values.
We are given an array of song “excitement” values. We need to count how many contiguous segments of this array can be selected such that inside the segment there exists at least one element that is unusually large compared to the rest of the segment.
We are given an album represented as a fixed sequence of songs in a circular disc player. The disc starts at the first song and always moves forward in order, wrapping back to the beginning after the last song. Noah does not simply listen sequentially.
We are given a set of $n$ distinct disks labeled from $1$ to $n$. The goal is to place all of them on a single line, forming a permutation of these labels.
We are placed in a hidden 2D grid of size up to 100 by 100. Inside this grid lie at most ten ships, and each ship is always a straight segment of exactly five consecutive cells, either horizontal or vertical. Ships never overlap, but they can touch each other.
We are given a set of points in the plane, each representing a bakery. We are allowed to build a street system that consists of exactly two infinite families of straight, parallel lines that are perpendicular to each other.
We are placed on the top-left tile of an $n times n$ grid and allowed to walk across the grid using two different “knight-like” movement rules.
The island can be seen as a planar drawing of line segments. Each fence is a straight segment, and fences may cross each other, creating a subdivision of the plane into multiple polygonal regions. Each region corresponds to a piece of land owned by one person.
We are given a multiset of integers, and we are allowed to build a single arithmetic expression that uses each integer exactly once. The only operations available are addition and multiplication, and we may freely insert parentheses to control evaluation order.
We are given a fixed network of planets in 3D space, where certain pairs of planets are connected by bidirectional space highways. Each highway is a straight segment with a known length determined by Euclidean distance between its endpoints.
Two integers are given as strings of digits, forming a numerator and denominator on each side of a fraction equation.
We are given a weekly calendar encoded as a 7 by 24 grid. Each row corresponds to a day and each column corresponds to an hour. A cell is either free or blocked. Free means you are available at that day and hour, blocked means you are busy.
We maintain a collection of variables, all starting from the same base value 2023. Two kinds of operations are applied online. One operation replaces one variable by raising it to the power of another variable.
We are simulating a circle of positions numbered from 1 to n, each initially occupied by exactly one player whose label matches the chair number. The system then applies a sequence of global transformations that move every currently alive player at once.
We are given a set of brick types, each with a fixed length, and we are allowed to use an unlimited number of bricks of each type. The goal is to construct an infinitely tall wall of fixed width w. Each row is a sequence of bricks whose total length is exactly w.
We are given a set of chargers, each with a fixed physical length, and a long power strip that contains a limited number of sockets arranged in a line.
Each planet chooses exactly one other planet to “guard”. You can think of this as a directed graph where every node has exactly one outgoing edge, from node i to node A[i]. We want to select a set of planets S to place inside a protective barrier.
We are given a permutation of columns. A laser starts at each column at the top of a grid and travels downward through a sequence of rows.
We are given a directed grid where every cell contains exactly one instruction: move one step north, east, south, or west. The grid is not a finite board for movement, instead it is repeated infinitely in all directions, like a wallpaper.
We are given a single integer array and asked to consider every contiguous slice of it. For each slice, we compute the sum of its elements and check whether that sum is even.
We are given an undirected graph with at most 12 vertices. Each edge can be independently oriented in one of three ways: left-to-right, right-to-left, or removed entirely.
We are given two integer sequences of the same length. From any contiguous segment of indices, we can compute two values: the sum of the chosen segment in the first array and the sum of the same segment in the second array.
We are given a sequence of gear wheels arranged in a fixed left-to-right order, where each gear has a number of teeth. A valid chain is a subsequence of these gears, preserving original order, such that every adjacent pair can directly mesh.
We are given a string $S$ of length $N$, and we want to extract a special “generator” string from it. This generator, called the key, is defined as the shortest possible substring that can reproduce the entire original string if we repeatedly place copies of it, allowing…
We start from a fixed labeled tree on $N le 25$ vertices. This tree is not the object we are modifying freely, it is a mandatory backbone: every valid graph $G$ must contain all tree edges.
Each bank starts with a fixed amount of money it must distribute, but it cannot give more than $K$ to any single stakeholder. Each stakeholder already has some initial wealth and also has an upper cap on how much total money they are allowed to end up with after all transfers.
We are given a static array and multiple independent range queries. For each query, we look at a segment from index L to index R, with the guarantee that there are at least four elements inside it.
We are given a circular cake centered at the origin, and each student makes exactly one straight cut. Every cut is a line segment whose endpoints lie on the circumference of the circle, so each cut behaves like a chord.
We are given a list of integers and need to determine whether there exists at least one pair of distinct elements whose greatest common divisor is greater than one.
We are given a chain of coin types where each type is more valuable than the previous one. The exchange rate is multiplicative along the chain: a fixed number of coins of type i can be exchanged for one coin of type i+1.
We are given two types of square tiles that must be packed into a fixed-width rectangular box. The box has width $K$ and an unknown length $X$, and all tiles must be placed axis-aligned, without overlap. One type of tile is a $2 times 2$ square, and there are $A$ of them.
We are simulating a snake moving on a fixed n by m grid that always follows a deterministic “snake-like” path: it scans left to right across each row, and when it reaches the end of a row it jumps to the start of the next row, wrapping from the bottom-right back to the…
We are asked to decide whether it is possible to choose a mix of two types of bakery items so that two constraints are satisfied at the same time. Vasилиса must buy exactly one item for each of her N guests, so the total number of items is fixed to N.
We are maintaining a collection of numbered segments on a number line. Each segment starts with a given interval, and all initial segments share the same length, though that fact mainly matters as a structural hint rather than something we explicitly exploit.
We are given an $n times n$ table that was originally constructed from an unknown sequence $a1, a2, ldots, an$. Every off-diagonal cell contains the product of two elements of this sequence, specifically $B{i,j} = ai cdot aj$ for $i neq j$.
We are given a string s that contains lowercase letters and wildcard characters ?, and another string t consisting only of lowercase letters. Before anything else happens, all ? characters in s must be replaced by lowercase letters chosen by us.
We are given two kinds of words. One group contains short words, all of equal length a, and there are n distinct words of this type. The other group contains long words, all of equal length b, and there are m distinct words of this type, with a < b.
We are given a single line string that is meant to represent an arithmetic equality between two expressions. Each expression can contain decimal digits and the symbols + and -.
We are given a set of points in the plane and asked to reconstruct the boundary of their convex hull in two different levels of detail.
We are looking at a two-player impartial game played on a single pile of stones. The game starts with $N$ stones, and players alternate turns. On a turn, the current player removes between $1$ and $K$ stones inclusive.
We are playing a two-player take-away game with a single pile of stones. Players alternate turns, and on each turn a player removes between 1 and K stones inclusive.
We are given a list of scientific papers, each with a current citation count. The Hirsch index we want to reach is a threshold H, which means we need at least H papers whose citation counts are each at least H.
We are asked to count integers in a range $[a, b]$ such that each integer has exactly seven positive divisors. The task is not about factoring arbitrary numbers efficiently online, but about understanding the structure of numbers whose divisor function equals seven.
We can view the factory as a directed graph on $N$ workshops. Every workshop from $1$ to $N-1$ already has exactly one outgoing conveyor, so each of these nodes points to a fixed next node. Workshop $N$ is newly introduced and initially has no outgoing conveyor.
We are given a positive integer $n$, and we conceptually form a huge product where each integer $i$ from 1 to $n$ is raised to its own power $i$, and all these values are multiplied together: $$1^1 cdot 2^2 cdot 3^3 cdots n^n$$ The task is not to compute this enormous number…
We are simulating a simplified virtual memory system where pages can either be in fast physical memory or stored on disk. At the start, the first m pages are already loaded into physical memory, and the remaining pages are on disk. Then a sequence of k page accesses is executed.
We are given an $n times n$ chessboard and a bishop placed on a starting square. The bishop can move any number of cells in a single move, but only along diagonals.
We are working with correctly balanced parentheses strings of length $2n$. Such a string can be thought of as a sequence of $n$ opening brackets and $n$ closing brackets arranged so that at every prefix, openings are never outnumbered by closings, and at the end the counts match.
We are asked to build a generator that outputs pairs of integers $(a, b)$ satisfying $1 le a le b le k$, and each valid pair must be produced with equal probability whenever we request a new value.
We are given a final set of species labeled from 1 to n, where label corresponds to fitness and also to the order constraint that parents always have smaller labels than children.
We are given the current snapshot of all bacteria that are alive on an infinite integer grid. We are told that originally there was a single bacterium at some unknown grid point, and after some unknown number of minutes, bacteria spread through Manhattan-adjacent moves.
We start with a single circular RNA string made of four possible characters. Over time, this structure is transformed by two kinds of operations that interact in a very specific way.
We are given a linear habitat made of forests, each forest having a numeric “resistance” value. A wildfire can start at a chosen forest with some initial integer strength and then spread left and right across adjacent forests.
We are given a sequence of tasks ordered by priority from first to last, and each task consumes a fixed amount of ATP to complete. Jasmine has a daily ATP budget of $m$, and she cannot repeat tasks. The twist is that she does not always consider all tasks.
We are given two DNA strings of equal length, composed only of the characters A, T, C, and G. Each position represents a nucleotide, and we are asked to decide whether the second string can be obtained from the first using only mutations that swap complementary bases.
We are given a layered structure where each layer contains a certain number of nodes. Between every pair of consecutive layers, every node in the left layer is connected to every node in the right layer.
A cell starts with c chromosomes and divides into two daughter cells containing a and b chromosomes. The division is considered correct only if every chromosome ends up in exactly one of the two daughter cells.
We are given a directed graph whose edges are labeled with decimal digits. Starting from vertex 1, we may walk forever by following directed edges. The sequence of edge labels becomes the decimal expansion of a number between 0 and 1.
We are given a partially specified array of length $N$, where each position is either fixed to one of the values $1,2,3$ or is a wildcard that can be replaced independently by any of the three values. Every full assignment produces a concrete integer array.
We are given several independent test cases. Each test case describes a set of shooting lanes, where lane i contains Ai targets arranged in a line. Tim will fire a sequence of shots, and each shot is assigned to exactly one lane.
Each clause is the product of three variables, where every variable is either 0 or 1. The whole expression is the sum of all clause values. We are asked whether there is an assignment of the variables such that this sum is odd.
We are given a multiset of integers representing letters, where each value from 1 up to NM is just a symbol in a totally ordered alphabet. The task is to split all these symbols into N words, each word having exactly M letters, using every occurrence exactly once.
For each test case, we are given an array of integers. We must construct the smallest positive integer m such that every array element shares a common divisor greater than 1 with m. In other words, for every value ai, the greatest common divisor gcd(ai, m) must be at least 2.
The system we are validating is extremely simple: for each test case, we are told how many tests a program was supposed to run and how many of them it actually passed. From this, we decide whether the program fully succeeded or not.
We are given a binary string, and we are allowed to take any contiguous segment of it. Each such segment is interpreted as a binary number, and we want to know whether at least one of these numbers is a prime.
We are given an integer starting point and a forbidden digit. From the starting number, we are allowed to repeatedly increase it by one. The goal is to reach the first number at or after the starting point whose decimal representation does not contain the forbidden digit at all.
For each test case, we are given a positive integer n. We must count how many positive integers in the range from 1 to n have an odd number of decimal digits. The value of n can be as large as 10^18. That immediately rules out any solution that examines every number individually.
Each test case gives a collection of juice bottles, where the i-th bottle contains a certain number of liters. Abdelaleem will serve exactly m friends, and for each chosen bottle he is allowed to pour the same integer amount of liters into every friend’s cup.
We are given an array and asked to think about all ways to choose exactly k elements while preserving order, although the order constraint does not affect which values end up selected, only which subsets are valid.
We are simulating a small training management system that keeps track of students and their accumulated bonus points. Each student has a fixed identity given by an index from 1 to n and an associated name. Initially, all students start with zero points.
We are given three integers $l$, $r$, and $k$. The task is to count how many integers $x$ in the range $[l, r]$ satisfy a condition derived from a digit-selection construction: the number $x$ must be representable as a concatenation of chosen “digits”, where each chosen…
We maintain a mutable string over lowercase letters. Two operations are supported: point updates that overwrite a single position, and queries over a substring asking whether that segment can be turned into a palindrome after changing at most one character inside the segment.
Let $\rho(x)$ denote the number of trailing zero bits of $x$, that is, the number of right shifts required until the least significant bit becomes $1$.
Each test case describes a right-angled triangle using its base and height. The task is not to compute the actual geometric area, but instead to output twice that area. A right triangle’s area is computed as half of the product of its base and height.
Let $i$ be the index, $0 \le i < 12\cdot 10^6$, and write q = \left\lfloor \frac{i}{12} \right\rfloor,\qquad r = i - 12q,\qquad 0 \le r < 12.