brain
tamnd's digital brain — notes, problems, research
43815 notes
nA positive integer n is considered B-trivisible if the sum of all different prime factors of n which are not larger tha
The problem asks us to determine whether a given integer reads the same forward and backward. Such numbers are called palindromes. For example, the number 121 is a palindrome because reversing its digits still produces 121.
A peerless tree is a tree with no edge between two vertices of the same degree.
The problem gives us an integer array called nums and another integer called target. Our task is to find two different elements in the array whose sum equals target, then return their indices.
Solution to Project Euler Problem 986.
The problem gives us an array of positive integers called nums and a positive integer called target. We need to find the smallest possible length of a contiguous subarray whose sum is greater than or equal to target.
A round clock only has three hands: hour, minute, second.
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.
There are N seats in a row.
For a positive integer n construct a graph using all the divisors of n as the vertices.
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.
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 minimum bounding square of a triangle is the smallest square that can be drawn which fully covers the triangle.
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
Solution to Project Euler Problem 990.
The problem gives a Roman numeral string and asks us to convert it into its corresponding integer value. Roman numerals use seven symbols: Symbol Value --- --- I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Most Roman numerals follow a simple additive rule.
NOTE: This problem is related to Problem 882.
A composition of n is a sequence of positive integers which sum to n.
A palindromic number reads the same both ways.
We define nu2(n) to be the largest integer r such that 2^r divides n.
- A Sierpiński graph of order-1 (S1) is an equilateral triangle.
For the year 2025 Given positive integers a and b, the concatenation ab we call a 2025-number if ab = (a+b)^2.
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.
Consider a stack of bottles of wine.
This problem asks us to write a shell script that reads a text file named words.txt and computes how many times each word appears. After counting the occurrences, the script must print every unique word together with its frequency, sorted in descending order of frequency.
Let operatorname{smpf}(n) be the smallest prime factor of n.
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,
A bouncing point moves counterclockwise along a circle with circumference 1 with jumps of constant length l lt 1, until
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.
This problem asks us to determine a valid order in which courses can be completed given prerequisite relationships between them. You are given numCourses, which represents the total number of courses labeled from 0 to numCourses - 1.
This problem asks us to process a text file named file.txt and print only the phone numbers that match one of two valid formats. The valid formats are: and In both formats, every x represents a single digit from 0 to 9.
nStarting at zero, a kangaroo hops along the real number line in the positive direction.
The problem asks us to implement a simplified version of the C/C++ atoi function, which converts a string into a 32-bit signed integer. The conversion process is strict and follows several rules in a specific order.
Solution to Project Euler Problem 974.
For a positive integer n and digits d, we define F(n, d) as the number of the divisors of n whose last digits equal d.
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The problem asks us to compute the largest difference between two consecutive elements after sorting the array. At first glance, this may seem straightforward: sort the array, then scan through adjacent pairs to find the maximum difference.
Solution to Project Euler Problem 980.
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
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.
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
Define the sequence a(n) as the number of adjacent pairs of ones in the binary expansion of n (possibly overlapping).
Solution to Project Euler Problem 976.
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
We call a triangle fortunate if it has integral sides and at least one of its vertices has the property that the distanc
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 =
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 given integer R consider all primitive Pythagorean triangles that can fit inside, without touching, a circle with
The problem asks us to transform a string into a zigzag pattern across a fixed number of rows, then read the characters row by row to produce the final result.
This problem asks us to transpose the contents of a text file. Transposing means converting rows into columns and columns into rows. Every word in the input file is separated by a single space, and each row contains the same number of columns. The input is a file named file.txt.
Solution to Project Euler Problem 994.
A group of k(k-1) / 2 + 1 children play a game of k rounds.nAt the beginning, they are all seated on chairs arranged in
Define M(n) to be the minimum number of matchsticks needed to represent the number n.
This problem asks us to print exactly the 10th line from a text file named file.txt. The file contains multiple lines of plain text, and each line is separated by a newline character. The input is not provided as function arguments like many algorithm problems.
Solution to Project Euler Problem 996.
A unitary divisor of a positive integer n is a divisor d of n such that gcdleft(d,frac{n}{d}right)=1.
A clock sequence is a periodic sequence of positive integers that can be broken into contiguous segments such that the s
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
There is a plane on which all points are initially white, except three red points and two blue points.
Two players play a game with two piles of stones.
An L-expression is defined as any one of the following: - a natural number; - the symbol A; - the symbol Z; - the symbol
A deck of cards contains R red cards and B black cards.
Given nge 2 bowls arranged in a circle, mge 2 balls are distributed amongst them.
Given is an integer sided triangle ABC with BC le AC le AB.
Let sn be the n-th positive integer that does not contain three consecutive ones in its binary representation.
Starting with one piece of integer-sized rectangle paper, two players make moves in turn.
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 game is played with three piles of stones and two players.
nThe hyperbolic plane can be represented by the open unit disc, namely the set of points (x, y) in Bbb R^2 with x^2 + y^
Solution to Project Euler Problem 984.
Consider the following recurrence relation: Note that a0 is the golden ratio.
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.
Let P(n) be the number of permutations of 1,2,3,ldots,2n such that: 1.
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 988.
Three friends attempt to collectively choose one of n options, labeled 1,dots,n, based upon their individual preferences
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
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
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
This problem models course dependencies as a directed graph. Each course is represented as a node, and each prerequisite relationship is represented as a directed edge. If prerequisites[i] = [a, b], that means course b must be completed before course a.
Two players play a game with at least two piles of stones.
Consider the consecutive primes p1 = 19 and p2 = 23.
It is easily proved that no equilateral triangle exists with integral length sides and integral area.
Consider the number 48.
In a tournament there are n teams and each team plays each other team twice.
ABC is an integer sided triangle with incenter I and perimeter p.
Consider n coins arranged in a circle where each coin shows heads or tails.
Consider the set Ir of points (x,y) with integer co-ordinates in the interior of the circle with radius r, centered at t
A segment is uniquely defined by its two endpoints.
For any two strings of digits, A and B, we define F{A, B} to be the sequence (A,B,AB,BAB,ABBAB,dots) in which each term
There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In
Circles A and B are tangent to each other and to line L at three distinct points.
A window into a matrix is a contiguous sub matrix.
Let N be a positive integer and let N be split into k equal parts, r = N/k, so that N = r + r + cdots + r.
The kernel of a polygon is defined by the set of points from which the entire polygon's boundary is visible.
A sequence of rooted trees Tn is constructed such that Tn has n nodes numbered 1 to n.
For each integer p gt 1 coprime to 10 there is a positive divisibility multiplier m lt p which preserves divisibility by
In the hexadecimal number system numbers are represented using 16 different digits: The hexadecimal number mathrm{AF} wh
An even positive integer N will be called admissible, if it is a power of 2 or its distinct prime factors are consecutiv
We call an integer sided triangle n-pandigital if it contains one angle of 120 degrees and, when the sides of the triang