brain
tamnd's digital brain — notes, problems, research
42715 notes
This problem models a chain reaction of falling dominoes. We are given a string where each character represents the initial state of a domino in a row. A domino can be in one of three states: - 'L' means the domino has been pushed to the left.
We have n fish in a lake. Every day, exactly one unordered pair of currently alive fish is chosen uniformly at random. When fish i meets fish j, fish i eats fish j with probability a[i][j], and fish j eats fish i with probability a[j][i] = 1 - a[i][j].
We have a rectangular board where some cells are already blocked by and the remaining cells . must be covered by polyominoes. The allowed pieces are extremely flexible: any connected shape consisting of 2, 3, 4, or 5 cells may be used, with arbitrary rotations and reflections.
The problem requires rearranging spaces in a given string text so that all words are separated by the maximum possible e
This problem gives us a list of points on a 2D plane, where each point is represented as [x, y]. We need to find the widest vertical area that contains no points strictly inside it. A vertical area is defined by two vertical lines.
The problem asks us to compute the minimum number of edit operations needed to transform one string into another. The allowed operations are insertion, deletion, and replacement of a single character. Each operation has a cost of exactly one.
This problem asks us to compute several descriptive statistics-minimum, maximum, mean, median, and mode-from a very large sample of integers ranging from 0 to 255.
The problem gives us a two dimensional grid where each cell contains either '1' or '0'. A cell containing '1' represents land, while a cell containing '0' represents water. An island is defined as a group of connected land cells.
The folders are displayed in a grid with exactly m columns per row. Folder 1 is in the top-left corner, folder 2 is next to it, and so on. After every m folders we move to the next row. A rectangular frame selection toggles every folder inside the rectangle.
This problem asks us to identify every (actorid, directorid) pair where an actor and a director have collaborated at least three times. The input is a database table named ActorDirector. Each row represents one collaboration event between an actor and a director.
This problem asks us to determine how many students are doing homework at a specific point in time, given arrays represe
We have a tree where each vertex initially contains some number of beavers. The robot starts at a fixed vertex s. Every time it traverses an edge from u to v, it immediately eats exactly one beaver at v. If v already has zero beavers left, the move is impossible.
This problem asks us to identify all customers who have purchased every product listed in the Product table. In other words, a customer is eligible for the output if, for each productkey in the Product table, there exists a corresponding row in the Customer table where that…
Each ticket is described by two positive integers. The first is the series number a, the second is the ticket number inside that series b.
We have a set of horizontal blind stripes of varying lengths, and our goal is to construct a rectangular blind for a window using these stripes. Each stripe can be cut into smaller pieces, but pieces cannot be shorter than a given minimum length, l.
We are given a tree, and two independent probability distributions over its vertices. One distribution chooses the starting vertex of a DFS, the other chooses the target vertex where the search stops.
This problem asks us to determine whether a given integer n is an exact power of four. In other words, we need to check whether there exists some integer x such that: Examples of powers of four are: The input consists of a single integer n, and the expected output is a boolean…
The problem describes a frog trying to cross a river by jumping across stones placed at specific positions. The input array stones contains the positions of all stones in sorted ascending order. The frog starts on the first stone, which is always at position 0.
A square of side length b<1 is rolling around the inside of a larger square of side length 1, always touching the larger
For a positive integer n we define tau(n) to be the count of the divisors of n.
This problem asks us to determine whether a target value exists inside a rotated sorted array that may contain duplicate values. The original array was sorted in non-decreasing order, meaning values are arranged from smallest to largest, and duplicates are allowed.
The problem asks us to design and implement a Trie, also called a Prefix Tree. A Trie is a specialized tree structure for storing strings in a way that makes prefix-based operations very efficient.
A full k-ary tree is a tree with a single root node, such that every node is either a leaf or has exactly k ordered chil
The prime factors of 13195 are 5, 7, 13 and 29.
Two players play a game with two piles of stones.
The problem asks us to count how many prime numbers exist that are strictly smaller than a given integer n. A prime number is a positive integer greater than 1 that has exactly two divisors: 1 and itself. Examples of prime numbers include 2, 3, 5, 7, and 11.
Solution to Project Euler Problem 988.
A permutation pi of 1, dots, n can be represented in one-line notation as pi(1),ldots,pi(n) .
A peerless tree is a tree with no edge between two vertices of the same degree.
We define the unlucky prime of a number n, denoted u(n), as the smallest prime number p such that the remainder of n div
A deck of cards contains R red cards and B black cards.
A multiplicative function f(x) is a function over positive integers satisfying f(1)=1 and f(a b)=f(a) f(b) for any two c
nLet I(a, b, c) be the largest possible area of intersection between a triangle of side lengths a, b, c and a circle whi
For each prime p and each positive integer n define two polynomials: Let S(p) be the smallest positive integer s such th
nThis game starts with a positive integer.
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
The problem asks us to reverse the digits of a signed 32-bit integer. Given an integer x, we must return a new integer whose digits appear in reverse order while preserving the sign. For example, if the input is 123, reversing the digits produces 321.
The problem gives us two arrays of coin values. The first array represents coins in Rudolf's left pocket, and the second array represents coins in his right pocket.
A Pythagorean triplet is a set of three natural numbers, a lt b lt c, for which, For example, 3^2 + 4^2 = 9 + 16 = 25 =
Let theta=sqrt{-2}. Define T to be the set of numbers of the form a+btheta, where a and b are integers and either agt 0,
The problem asks us to reverse the binary representation of a 32-bit integer. Instead of reversing the decimal digits of a number, we reverse the order of its individual bits.
There is a plane on which all points are initially white, except three red points and two blue points.
Given is an integer sided triangle ABC with BC le AC le AB.nk is the angular bisector of angle ACB.nm is the tangent at
Let Sn be an integer sequence produced with the following pseudo-random number generator: Let A(i, j) be the minimum of
In a standard 52 card deck of playing cards, a set of 4 cards is a Badugi if it contains 4 cards with no pairs and no tw
The problem asks us to determine whether two strings, s and t, are isomorphic. Two strings are considered isomorphic if there exists a one-to-one mapping between characters in s and characters in t such that replacing every character in s according to this mapping produces t.
The problem asks us to compute the bitwise AND of every integer in the inclusive range [left, right]. For example, if left = 5 and right = 7, the numbers in the range are: Applying bitwise AND across all values: So the answer is 4.
Given is an integer sided triangle ABC with BC le AC le AB.
Two players A and B are playing a variant of Nim.
There are xyz dice arranged in an x times y times z box such that touching faces have the same value.
A clock sequence is a periodic sequence of positive integers that can be broken into contiguous segments such that the s
This problem asks us to determine whether a given positive integer n is a happy number. A happy number is defined through a repeated transformation process. Starting with the original number, we repeatedly replace it with the sum of the squares of its digits.
Consider the problem of determining a secret number from a set 1, ..., N by repeatedly choosing a number y and asking "I
Solution to Project Euler Problem 983.
A bouncing point moves counterclockwise along a circle with circumference 1 with jumps of constant length l lt 1, until
We are given d days and a target total number of study hours, sumTime. For every day, Peter must study at least minTime[i] hours and at most maxTime[i] hours. The task is to construct any valid schedule whose total sum is exactly sumTime.
This problem provides a database table named Person with two columns: The id column is unique because it is the primary key. The email column may contain duplicate values, meaning multiple rows can share the same email address.
Solution to Project Euler Problem 979.
Consider a stack of bottles of wine.
nDefinennas the sum of 2^a3^b5^c7^d11^e over all quintuples of non-negative integers (a, b, c, d, e) such that the sum o
Let's call a pair of positive integers p, q (p lt q) reciprocal, if there is a positive integer rlt p such that r equals
Solution to Project Euler Problem 987.
An irrational number x can be uniquely expressed as a continued fraction [a0; a1,a2,a3,dots]: where a0 is an integer and
Solution to Project Euler Problem 984.
nStarting at zero, a kangaroo hops along the real number line in the positive direction.
An L-expression is defined as any one of the following: - a natural number; - the symbol A; - the symbol Z; - the symbol
Solution to Project Euler Problem 973.
The classical eight queens puzzle is the well known problem of placing eight chess queens on an 8 times 8 chessboard so
Solution to Project Euler Problem 978.
Solution to Project Euler Problem 976.
For coprime positive integers a and b, let C{a,b} be the curve defined by: where t varies between 0 and 2pi.
Solution to Project Euler Problem 980.
Solution to Project Euler Problem 977.
Let B(n) be the smallest number larger than n that can be formed by rearranging digits of n, or 0 if no such number exis
Solution to Project Euler Problem 991.
Solution to Project Euler Problem 975.
A Young diagram is a finite collection of (equally-sized) squares in a grid-like arrangement of rows and columns, such t
Let G(n) denote the largest possible area of an n-gona polygon with n sides contained in the region (x, y) in Bbb R^2: x
nThere are n distinct piles of stones, each of size n-1.
A game is played with three piles of stones and two players.
A composition of n is a sequence of positive integers which sum to n.
Let B(n) be the smallest number larger than n that can be formed by rearranging digits of n, or 0 if no such number exis
We are given an array of non-negative integers. In one operation, we choose an index $i$ such that $2 le i le n-1$, and
The four adjacent digits in the 1000-digit number that have the greatest product are 9 times 9 times 8 times 9 = 5832.
Solution to Project Euler Problem 996.
The problem asks us to remove every node from a singly linked list whose value is equal to a given integer val. After all matching nodes are removed, we must return the head of the modified linked list.
A round clock only has three hands: hour, minute, second.
The problem gives a string s and asks for the length of the longest substring that contains no repeated characters. A substring is a continuous section of the string. This detail matters because characters must remain adjacent.
Let operatorname{smpf}(n) be the smallest prime factor of n.
NOTE: This problem is related to Problem 882.
Tatami are rectangular mats, used to completely cover the floor of a room, without overlap.
The problem gives us the root node of a binary tree and asks us to determine which nodes are visible when looking at the tree from the right side.
Solution to Project Euler Problem 994.
The Euclidean algorithm can be used to find the greatest common divisor of two positive integers.
The problem asks us to find the longest substring of a given string that is also a palindrome. A palindrome is a sequence that reads the same forward and backward. The substring must be contiguous, which means the characters must appear next to each other in the original string.
A permutation pi of 1, dots, n can be represented in one-line notation as pi(1),ldots,pi(n) .
Let sigma(n) be the sum of the divisors of n.
Let sn be the n-th positive integer that does not contain three consecutive ones in its binary representation.
The problem gives an array called height, where each element represents the height of a vertical line drawn on a coordinate plane. The line at index i starts at (i, 0) and ends at (i, height[i]).
We are given a string and want to remove the minimum number of characters so that the resulting string no longer contains "pie" or "map" as a substring.