Questions tagged [math]

The challenge involves mathematics. Also consider using more specific tags: [number] [number-theory] [arithmetic] [combinatorics] [graph-theory] [geometry] [abstract-algebra].

Filter by
Sorted by
Tagged with
-1
votes
0answers
51 views

Find the number of edge in a graph [closed]

In graph theory, you can describe a graph using a letter and its number of vertices. For example, the complete graph with 5 vertices is denoted by K5 There are many identifiers for many family of ...
12
votes
27answers
2k views

Drawing one-liner

CodeDrawing one-liner Teaser Behold this formidable drawing: Can you draw this in a single stroke? Give it a try. Can you do this one, now: Give it a try. How it works These "make this drawing ...
10
votes
8answers
1k views

Integer Logarithm

Objective Take \$a \in ℤ_{>1}\$ and \$b \in ℤ_+\$ as inputs. Write a function \$f\$ such that: $$ f(a,b) = \left\{ \begin{array}{ll} \log_ab & \quad \text{if} \space \log_ab \in ℚ ...
36
votes
37answers
7k views

Is this a triangle?

Task Write a function/program that, given three positive integers a, b and c, prints a ...
33
votes
36answers
4k views

Lonely Multiplication

Based on this question from Code Review. Given precisely three positive integers, return the product of all of the distinct inputs. If none of the inputs are distinct, return 1. That is, implement ...
-2
votes
0answers
81 views

By what factor must you divide the perimeter of a circle to return the maximum quantity of sines with terminating decimals? [closed]

This is a question which occurred to me in a dispute about which way of calculating sines leads to the most numerically pleasing results. In particular, with numbers which can be handled exactly. The ...
30
votes
27answers
5k views

How far should I sum?

How far should I sum? The harmonic series is the "infinite sum" of all the fractions of the form \$\frac1n\$ for \$n\$ positive integer. I.e. the harmonic series is $$\frac11 + \frac12 + \frac13 + \...
-4
votes
0answers
40 views

A task with some matches [closed]

members) I got some task with 5 matches you must move 2 of them to make figure More details in the file https://www.sendspace.com/file/2zwnon
3
votes
1answer
207 views

Estimate the mean minimum Hamming distance

Task Inputs \$b \leq 100\$ and \$n \geq 2\$. Consider \$n\$ binary strings, each of length \$b\$ sampled uniformly and independently. We would like to compute the expected minimum Hamming distance ...
27
votes
24answers
4k views

Calculate the Progressive Mean™

Disclaimer: This challenge is inspired by a coding error I once made. Okay, time for a maths lesson. A normal mean average looks like this: ...
13
votes
12answers
590 views

Computing a specific coefficient in a product of polynomials

Generator functions This gives the context for why this challenge came to life. Feel free to ignore. Generator functions are a nice way of encoding the solution to a problem of combinatorics. You ...
-5
votes
5answers
284 views

Approximating the amount of prime numbers below `x`

Background We define the prime-counting function, \$\pi(x)\$, as the number of prime numbers less than or equal to \$x\$. You can read about it here. For example, \$\pi(2) = 1\$ and \$\pi(6) = 3\$. ...
33
votes
35answers
5k views

Shift right by half a bit

The challenge is to implement a program or function (subsequently referred to as "program") that takes a nonnegative integer \$n\$ as input and returns \$n\over\sqrt{2}\$ (the input divided by the ...
7
votes
1answer
492 views

Average number of strings with Levenshtein distance up to 4

This is a version of this question which should not have such a straightforward solution and so should be more of an interesting coding challenge. It seems, for example, very likely there is no easy ...
17
votes
10answers
399 views

Decomposition of a matrix in \$ SL_2(\mathbb{Z}) \$

Background The special linear group \$ SL_2(\mathbb{Z}) \$ is a multiplicative group of \$ 2 \times 2 \$ matrices whose elements are integers and determinant is 1. It is known that every member of \$...
2
votes
0answers
52 views

Compositional inverse of a power series [duplicate]

If \$f(x) = x + \sum_{i>1} a_ix^i\$ and \$g(x)=x+\sum_{i>1}b_ix^i\$ then there is a composite power series \$f(g(x))\$ also of this form. Given a power series \$f\$ the goal is to find a ...
19
votes
21answers
5k views

Largest monetary amount impossible to make with two types of coin

Suppose we have two different types of coin which are worth relatively prime positive integer amounts. In this case, it is possible to make change for all but finitely many quantities. Your job is to ...
15
votes
8answers
1k views

Is this quadrilateral tangential?

Related: Is this quadrilateral cyclic? Background A tangential quadrilateral is a quadrilateral which has an incircle: Examples include any square, rhombus, or a kite-like shape. Rectangles or ...
11
votes
4answers
2k views

Can you calculate the average Levenshtein distance exactly?

The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. The challenge is to compute ...
6
votes
1answer
565 views

Average number of strings with Levenshtein distance up to 3

The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. Given a binary string \$S\$ of ...
11
votes
1answer
251 views

Maximal 2-distance Sets

In the plane (\$\mathbb R^2\$) we can have at most five distinct points such that the distances from each point to every other point (except itself) can assume at most two distinct values. An example ...
15
votes
1answer
494 views

Is this ordinal prime?

You are given an countable ordinal \$1 < r < \varepsilon_0\$. Determine whether or not it is prime. If not, provide exactly two ordinals \$r_0, r_1 < r\$ such that \$r_0r_1 = r\$, following ...
12
votes
5answers
620 views

Define the finite field GF(9)

\$GF(9)\$ or \$GF(3^2)\$ is the smallest finite field whose order isn't a prime or a power of two. Finite fields of prime order aren't particurlarly interesting and there are already challenges for \$...
16
votes
1answer
248 views

Can this knot be colored with 3 colors?

In this challenge you will be asked to take a knot and determine if it can be colored in a particular way. First we draw a diagram of the knot. We use the standard way of drawing knots where we put ...
29
votes
5answers
2k views

Longest Prime Sums

Sandbox There are special sets S of primes such that \$\sum\limits_{p\in S}\frac1{p-1}=1\$. In this challenge, your goal is to find the largest possible set of primes that satisfies this condition. ...
21
votes
19answers
2k views

Smallest Fibonacci Multiples

Sandbox Background (not necessary for the challenge) A standard number theory result using the pigeonhole principle is the fact that given any natural number k, there is a Fibonacci number that is a ...
-2
votes
7answers
304 views

Interpreting the Wolfram Code

Introduction An elementary cellular automaton is a cellular automaton that is 1-dimensional and has 2 states, 1 and 0. These cellular automata are categorized based on a simple code: the Wolfram code,...
16
votes
17answers
3k views

Roll for Initiative!

Roll for Initiative! Introduction In tabletop games like Dungeons and Dragons, when you begin a battle, all involved parties roll for initiative. In DnD 5e, this is ...
17
votes
2answers
635 views

Find the number of n-by-n (-1, 0, 1) matrices with zero permanent as quickly as possible

The permanent of an \$n\$-by-\$n\$ matrix \$A = (a_{i,j})\$ is defined as: $$\operatorname{perm}(A)=\sum_{\sigma\in S_n}\prod_{i=1}^n a_{i,\sigma(i)}$$ For a fixed \$n\$, consider the \$n\$-by-\$n\$ ...
33
votes
28answers
4k views

How many times, are they multiples?

You are given three parameters: start(int), end(int) and list(of int); Make a function that returns the amount of times all the numbers between start and end are multiples of the elements in the list....
15
votes
3answers
2k views

How divisible are you?

You are to create a program which, when given a positive integer \$n\$, outputs a second program. This second program, when run, must take a second positive integer \$x\$ and output one of two ...
17
votes
4answers
1k views

Can Alice win the game?

Can Alice win the game? The game's rules are as follows. First, a finite non empty set of positive integers \$X\$ is defined. Then, Alice and Bob take turns choosing positive integers, with Alice ...
28
votes
4answers
4k views

How close are we, really?

Please note: this is a restricted-source challenge — see details below! Each natural number \$n\$ has 10 faces: its decimal representations in bases \$1\$ through to \$10\$. For example, the 10 faces ...
12
votes
8answers
506 views

Decorate Pascal's Triangle

Although what is a Pascal's triangle is well-known and we already can generate it, the task is now different: Output \$n\$ first lines of the Pascal's triangle as colored bricks. Color number is ...
2
votes
1answer
126 views

Gaussian integer division reminder [closed]

Gaussian integer is a complex number in the form \$x+yi\$, where \$x,y\$ are integer and \$i^2=-1\$. The task is to perform such operation for Gaussian integers \$a,b\$, that \$a=q \cdot b+r\$ and \$|...
11
votes
23answers
2k views

N-Dimensional Cartesian Product

Introduction The Cartesian product of two lists is calculated by iterating over every element in the first and second list and outputting points. This is not a very good definition, so here are some ...
11
votes
9answers
984 views

Area of diagonal-folded regular polygon

I have a piece of paper whose shape is a regular n-gon with side length 1. Then I fold it through some of its diagonals. What is ...
2
votes
5answers
229 views

Proportion of strings with ascending letters [closed]

Challenge Construct n strings, each with three distinct letters, chosen randomly with equal probability. Print the proportion ...
15
votes
61answers
4k views

Average Two Letters

Introduction Every letter in the English alphabet can be represented as an ASCII code. For example, a is 97, and ...
9
votes
8answers
363 views

1D Shikaku Validation

Shikaku is a 2D puzzle. The basic rundown of it is that a rectangular grid has some numbers in it, and you want to partition the grid into rectangular components such that each component contains ...
8
votes
13answers
367 views

Print all the ways to aquire specific number using only specific numbers

Let's say we have some arbitrary number: For example 25. We also have some "tokens" (poker chips, money, something similar) with different values. Values of tokens are ...
14
votes
13answers
1k views

Is it rectilinear?

Today's challenge: Given an ordered list of at least 3 unique integer 2D points forming a polygon, determine if the resulting polygon is Rectilinear. A polygon is rectilinear if every interior ...
27
votes
18answers
4k views

Fermat's Last Theorem, mod n

Fermat's Last Theorem, mod n It is a well known fact that for all integers \$p>2\$, there exist no integers \$x, y, z>0\$ such that \$x^p+y^p=z^p\$. However, this statement is not true in ...
10
votes
4answers
1k views

How compactly can your language perform accurate numerical integration?

WARNING: This challenge may need 128 bit floats.1 The task is to perform numerical integration. Consider the following three functions. \$ f(x) = cx^{c - 1}e^{-x^c} \$ \$ g_1(x) = 0.5e^{-x} \$ \$...
0
votes
1answer
128 views

Shooting gallery Puzzle!

Have you been shooting gallery? We are recently. In our shooting gallery cans and aluminum cans from under various drinks hang and stand. More precisely, they hung and stood. From our shots, banks ...
6
votes
4answers
323 views

Shorthand Combined Functions

I was doing some investigation into trig functions using compound angles recently, and noticed that the results are really long and tedious to write: $$ \cos(A+B) = \cos A \cos B - \sin A \sin B \\ \...
9
votes
3answers
478 views

How wavy is an array?

A wave of power \$k\$ is an infinite array that looks like \$1,2,\dots,k,k-1,\dots,1,\dots,k,\dots,1,\dots\$, and so on. For example, a wave of power 3 starts with \$1,2,3,2,1,2,3,2,1,...\$, and ...
24
votes
14answers
3k views

Are my triangles similar?

Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ...
24
votes
10answers
2k views

Fermat's polygonal number theorem

Fermat's polygonal number theorem states that every positive integer can be expressed as the sum of at most \$n\$ \$n\$-gonal numbers. This means that every positive integer can be expressed as the ...
15
votes
43answers
3k views

Find the percentage

We haven't had any nice, easy challenges in a while, so here we go. Given a list of integers each greater than \$0\$ and an index as input, output the percentage of the item at the given index of the ...

1 2 3 4 5 28