Questions tagged [math]

The challenge involves mathematics in some central way. Also consider using more specific tags, listed in the tag wiki info.

Filter by
Sorted by
Tagged with
9 votes
14 answers
1k views

ASCII-Plot the equation

You are given a polynomial function, in the following format: \$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$ where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$...
user avatar
10 votes
3 answers
276 views

Minkowski sum of two convex polygons

Background Minkowski addition is a binary operation on two sets of points (usually geometric objects) in the Euclidean space. The Minkowski sum of two sets \$A\$ and \$B\$ is formally defined as ...
user avatar
  • 64.7k
19 votes
21 answers
1k views

Binomial transform

Background Binomial transform is a transform on a finite or infinite integer sequence, which yields another integer sequence. The binomial transform of a sequence \$\{a_n\}\$ is given by $$s_n = \sum_{...
user avatar
  • 64.7k
19 votes
1 answer
595 views

Demonstrate some advanced abstract algebra

Consider a binary operator \$*\$ that operates on a set \$S\$. For simplicity's sake, we'll assume that \$*\$ is closed, meaning that its inputs and outputs are always members of \$S\$. This means ...
user avatar
26 votes
9 answers
2k views

Is it a valid Parker Square

5 Years ago, this happened, and then it became sort of a meme. Challenge The Challenge today is, to check if a "magic square" is a valid parker square. What is a Real Magic square? All the ...
user avatar
  • 4,621
10 votes
7 answers
402 views

Combinatorial Pipes

You're a plumber working on a house, and there's some pipes that must be connected at weird angles. You have 8°, 11.25°, 22.5°, 45°, and 90° fittings at your disposal, and you want to use as few as ...
user avatar
10 votes
5 answers
420 views

Rewrite strings without changing their order

Lexicographic Ordering For this challenge we will be talking about the lexicographic ordering of strings. If you know how to put words in alphabetical order you already understand the basic idea of ...
user avatar
  • 89.4k
9 votes
0 answers
316 views

Yet another digit insertion problem

Given a positive number \$n\$ we call another (not same as n) positive number \$m\$ good if we insert same digits in both n and m and the resulting fractional value is same. $$m/n = m_{\text{...
user avatar
  • 599
31 votes
82 answers
7k views

iHateOddNumbers

Task Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program. Example with ...
user avatar
7 votes
8 answers
531 views

Sums of square roots

Program the sequence \$R_k\$: all numbers that are sum of square roots of some(maybe one) natural numbers \$\left\{\sum_{i\in A}\sqrt i\middle|A\subset \mathbb{N}\right\}\$, in ascending order without ...
user avatar
  • 12.9k
2 votes
0 answers
141 views

Conic Sections (simplified)

Given the equation of a non-parabolic conic section, output its characteristics. Spec Some info on conic sections: for more info visit Wikipedia From an equation of the form \$ax^2+bx+cy^2+dy+E=0\$, ...
user avatar
12 votes
7 answers
775 views

Prime Factorization - but on the exponents too

Though there is a prime factorization challenge and it's here, this, I feel, will be a bit more interesting than that one. To understand this, let's have an example; I will use 5,184 for this. \$5184 =...
user avatar
0 votes
4 answers
164 views

Prime Factorization [duplicate]

Although there was a prime factors challenge posted ten years ago, it has tedious I/O and restricted time. In this challenge, your task is to write a program or function which takes an integer \$n \ge ...
user avatar
11 votes
30 answers
2k views

Triangle-style sequences

Consider the triangular numbers and their forward differences: $$ T = 1, 3, 6, 10, 15, 21, ... \\ \Delta T = 2,3,4,5,6, ... $$ If we alter \$\Delta T\$ so that it begins with a different integer, we ...
user avatar
24 votes
25 answers
1k views

Multiply elements of the dihedral group

This is a copy cat question of Simplify ijk string applied to the other nonabelian group of order 8. See also Dihedral group composition with custom labels. Challenge Given a string made of ...
user avatar
  • 2,085
45 votes
27 answers
2k views

Simplify ijk-string

Related: Multiply Quaternions Challenge Given a string made of ijk, interpret it as the product of imaginary units of quaternion and simplify it into one of the ...
user avatar
  • 64.7k
11 votes
15 answers
703 views

Calculate \$ \lfloor n \log_2(n) \rfloor \$, exactly

Given an integer \$ n \ge 2 \$, you need to calculate \$ \lfloor n \log_2(n) \rfloor \$, assuming all integers in your language are unbounded. However, you may not ignore floating-point errors - for ...
user avatar
7 votes
1 answer
481 views

Compute the size of intersections of sets

Input A positive integer N representing the size of the problem and four positive integers v, x, y, z. Output This is what your code should compute. Consider a set of N distinct integers and consider ...
user avatar
21 votes
18 answers
4k views

Convince me Gabriel's Horn is possible

From Wikipedia, Gabriel's Horn is a particular geometric figure that has infinite surface area but finite volume. I discovered this definition in this Vsauce's video (starting at 0:22) where I took ...
user avatar
19 votes
20 answers
1k views

Exact generalised harmonic numbers

The generalised harmonic number of order \$m\$ of \$n\$ is $$H_{n,m} = \sum_{k=1}^n \frac 1 {k^m}$$ For example, the harmonic numbers are \$H_{n,1}\$, and \$H_{\infty,2} = \frac {\pi^2} 6\$. These are ...
user avatar
25 votes
38 answers
2k views

Sum of first n terms of this series

Given a digit x (between 0 to 9, inclusive) and a number n, calculate the sum of the first n ...
user avatar
25 votes
10 answers
2k views

Floor of complex number

Background Complex floor is a domain extension of the mathematical floor function for complex numbers. This is used in some APL languages to implement floor , ...
user avatar
  • 64.7k
12 votes
10 answers
879 views

Optimal addition subtraction chain

An addition-subtraction chain, is a sequence \$a_1, a_2, a_3, ... ,a_n\$, such that \$a_1=1\$ and for all \$i > 1\$, there exist \$j,k<i\$ such that \$a_i = a_j \pm a_k\$. Your task, is given a ...
user avatar
26 votes
18 answers
2k views

Sum on a Fenwick Tree

Background Information: What is a Fenwick Tree? With a normal array, it costs \$O(1)\$ to access and modify an element, but \$O(n)\$ to sum \$n\$ elements. Working with a prefix sum array (an array ...
user avatar
  • 40.3k
8 votes
18 answers
1k views

Least notes money exchange

Suppose A and B are two good friends. A has borrowed \$n\$ dollar from B. Now B wants the money back from A and A is also ready to give it. But the problem is A has only \$x\$ dollar notes and B has \$...
user avatar
  • 12k
21 votes
24 answers
2k views

Delannoy numbers

Consider a grid from \$(0,0)\$ in the bottom-left corner to \$(m,n)\$ in the top-right corner. You begin at \$(0,0)\$, and can only move in one of these three ways: Directly north \$(+0, +1)\$, ...
user avatar
26 votes
7 answers
924 views

Recover polynomial \$f(x)\$ from \$f^2(x)\$

Related: Calculate \$f^n(x)\$, Polynomialception Challenge Given a polynomial \$f(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_k x^k\$ of order \$k\$, we can compute its composition with itself \$f\left(f(...
user avatar
  • 64.7k
11 votes
21 answers
3k views

Exciting Mario Kart Grand Prix - Minimize the point difference!

Introduction When playing Mario Kart the other day, an interesting question popped up when a Grand Prix with my 2 roommates, 9 AI drivers and myself seemed to be fairly close and therefore exciting ...
user avatar
23 votes
14 answers
2k views

Collatz, Sort, Repeat

Background The Collatz (or 3x+1) map (A006370) is defined as the following: $$ a(n) = \begin{cases} n/2, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \end{cases} $$ Now, let's ...
user avatar
  • 64.7k
15 votes
13 answers
2k views

Restricted-source, take this!

a.k.a. You Can Output Anything With Labyrinth Or Hexagony™ Challenge In a recent restricted-source challenge, I could print any character with only half of the allowed digits with very small character ...
user avatar
  • 64.7k
10 votes
2 answers
380 views

Quote a rational number

Quote notation[1] is a way of expressing rational integers in a precise, finite manner, based on the concept of \$p\$-adic numbers. The notation is in the form of a string of digits (\$0123456789\$) ...
user avatar
20 votes
13 answers
896 views

Duplicates in "n × hamming weight of n" sequence

Background The sequence in the title is A245788 "n times the number of 1's in the binary expansion of n" ("times" here means multiplication), which starts like this: ...
user avatar
  • 64.7k
1 vote
11 answers
242 views

Implement ΔList [duplicate]

Given a list of integers, such as {1, 4, 2, 8, 10}, TI-Basic's ΔList will determine the difference between every overlapping ...
user avatar
19 votes
17 answers
739 views

Convert superscripts to MathJax

CGCC hasn't always had MathJax. Back in the dark ages, it would have been necessary to write \$x^2\$ as (the horror!). In this challenge, you will be given some ...
user avatar
4 votes
16 answers
509 views

Participant number

A math Olympiad will be held, and participants are being registered. The highest number of participants is 100. Each participant is given an ID number. It is given in a sequence like \$100, 97, 94, 91,...
user avatar
  • 12k
20 votes
6 answers
1k views

You are kinda Replacable to Me

You are provided with a non-empty array \$A\$ of integers, all greater than 0. But what good is an array if the elements do not sum up to the number \$N\$ (also provided as input)... So to change that,...
user avatar
  • 4,920
26 votes
4 answers
594 views

The half-step of Fibonacci

Challenge Implement the 1-indexed sequence A054049, which starts like this: ...
user avatar
  • 64.7k
27 votes
13 answers
2k views

How many bystanders will help?

Flavortext The Bystander Effect is a phenomenon where individuals are less likely to help a victim if other people are present. The idea is that as there are more people around, the individual burden ...
user avatar
  • 40.3k
17 votes
16 answers
2k views

How hyperperfect am I?

A \$k\$-hyperperfect number is a natural number \$n \ge 1\$ such that $$n = 1 + k(\sigma(n) − n − 1)$$ where \$\sigma(n)\$ is the sum of the divisors of \$n\$. Note that \$\sigma(n) - n\$ is the ...
user avatar
24 votes
19 answers
1k views

Calculate Home Primes

The Home Prime of an integer \$n\$ is the value obtained by repeatedly factoring and concatenating \$n\$'s prime factors (in ascending order, including repeats) until reaching a fixed point (a prime). ...
user avatar
18 votes
17 answers
1k views

The meeker number sequence

The Meeker numbers are a 7 digit number in form of \$abcdefg\$, where \$a×b=10c+d\$ and \$d×e=10f+g\$. As an example \$6742612\$ is a meeker number, here \$6×7=10×4+2\$ and \$2×6=10×1+2\$, so it is a ...
user avatar
  • 12k
19 votes
2 answers
520 views

Determine Circles

Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given? Task Your ...
user avatar
  • 1,367
1 vote
4 answers
213 views

A problem of rarity [closed]

Given a positive input \$n > 0\$, output the amout of two types based on their rarity. The two types are called \$A\$ and \$B\$, we know the followings: \$n\$ is a limited input and the maximum is ...
user avatar
16 votes
19 answers
1k views

Multiplicative Persistence #2

We had a challenge on Multiplicative Persistence here. As a recap, to get a multiplicative persistence of a number, do these steps: Multiply all the digits of a number (in base \$10\$) Repeat Step 1 ...
user avatar
  • 4,621
25 votes
8 answers
2k views

Implement Ash's float division

Ash has a bit of an interesting float division algorithm. It's designed to never return NaN, and things like signed zero and infinity need to be handled. How it ...
user avatar
12 votes
4 answers
520 views

The Game of Cat And Mice | With Matrices

Challenge This coding challenge is to figure out how many rounds the cat can live. In a \$4\times4\$ matrix, there are a number of mice and exactly 1 cat. Example: $$ \begin{array} {|r|r|}\hline 🐭 &...
user avatar
  • 4,621
13 votes
9 answers
688 views

Truncate continued fractions

Related: Cleaning up decimal numbers Background A continued fraction is a way to represent a real number as a sequence of integers in the following sense: $$ x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \...
user avatar
  • 64.7k
23 votes
19 answers
2k views

Quoted rational numbers

Quote notation is a way of expressing rational numbers based on the concept of \$p\$-adic numbers, written in the form \$x'y\$. The quote indicates that the number to it's left (\$x\$) is "...
user avatar
22 votes
20 answers
2k views

Code the Levine sequence

Introduction Note that I learned it from a Numberphile Video, where Neil Sloane explains it better. I recommend you to watch his Video. But for a quick Introduction: The Levine Sequence is made from ...
user avatar
  • 4,621
5 votes
5 answers
128 views

Sample space of n consecutive coin flips [duplicate]

Taking a positive integer n as input, print the sample space of n consecutive coin flips. The coin is fair, with two sides ...
user avatar

1 2
3
4 5
34