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

learn more… | top users | synonyms

5
votes
4answers
87 views

Calculate the Gamma function for half-integer arguments

Gamma function is defined as It is a well-known fact that for positive integers it coincides with a properly shifted factorial function: Γ(n) = (n - 1)!. However, a less famous fact is Γ(1/2) = ...
13
votes
21answers
2k views

The rice and chess problem

An Indian legend tells the story of the alleged inventor of the chess game, who impressed the emperor of India with his game so much that he would get rewarded with anything asked. The man said he ...
9
votes
14answers
664 views

Probability of something happening at least n out of m times

Write a program or function, that given a success probability p, a number n and a number of trials m returns the chance of at least n successes out of m trials. Your answer must be precise to at ...
4
votes
15answers
265 views

Counting triangles with integer perimeter

Mary has given John two sticks of lengths a and b respectively, where a and b are positive integers. John is very curious. He would like to know how many triangles with integer perimeter can be ...
0
votes
1answer
87 views

Calculate the a ^ b WITHOUT using *, / and ^ [duplicate]

Challenge Your goal is, given two positive integer numbers a and b, to calculate (and output) a ^ b without using either multiplication, division and the power itself (not directly, at least). And, ...
30
votes
29answers
2k views

Compute the Adler-32 checksum

Background Adler-32 is a 32-bit checksum invented by Mark Adler in 1995 which is part of the widely used zlib library (also developed by Adler). Adler-32 is not as reliable as a 32-bit cyclic ...
8
votes
7answers
256 views

Find the repetend of the decimal representation!

In this challenge 2 years ago, we found the period of a unit fraction (1/n where n is a natural number). Now, your task is to write a program/function to find the repetend of a unit fraction. The ...
11
votes
4answers
241 views

ASCII Art Mayan Numerals

This challenge is simple. Given a number, output a ascii-art representation of the number, using the Mayan Base-20 numeral system. What is the Mayan system? The Mayans used base 20 to store ...
9
votes
7answers
841 views

Calculate the Kronecker Product

Related, but very different. In the examples below, A and B will be 2-by-2 matrices, and the matrices are one-indexed. A Kronecker product has the following properties: A⊗B = A(1,1)*B ...
18
votes
7answers
948 views

Generate n digits of Gijswijt's sequence

Introduction Gijswijt's sequence (A090822) is famously really, REALLY slow. To illustrate: The first 3 appears in the 9th term (alright). The first 4 appears in the 220th term (a long way away, but ...
6
votes
7answers
445 views

Find the Matrix Power

Problem Create a program or function that can calculate the result of a matrix raised to the nth power. Your code will take an arbitrary square matrix A and a non-negative integer n, and return a ...
16
votes
8answers
728 views

Transform a matrix

Write a program or function where a matrix A (maximum value of dimensions of the matrix is 100) is transformed to a new matrix B. Each element of the new matrix B is the sum of the positive neighbors ...
5
votes
3answers
130 views

Taylor Series of a Function with Periodic Derivatives

Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single ...
11
votes
10answers
579 views

Permutations with Indistinguishable Items

Given a list of integers, output the number of permutations of the integers, with indistinguishable permutations counted once. If there are n integers, and each group of indistinguishable numbers has ...
19
votes
11answers
1k views

Polynomialception

Given two polynomials f,g of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. f(g(x)) (a.k.a. the composition (fog)(x) of the ...
7
votes
13answers
566 views

Linear Independence

Given a set of vectors all of the same positive finite dimension, output a falsey value if they are linearly dependent and a truthy value if they are linearly independent. A set of vectors v1, v2, ... ...
7
votes
17answers
916 views

Form tiles in a rectangular ring

Given the input tilesX and tilesY create a method that would make a rectangular ring from the tiles. The function must order the tiles in a ring like this: tilesX and tilesY are always positive ...
9
votes
2answers
323 views

Find the area of a polygon

Given consecutive side lengths s1, s2, s3... s_n of an n-gon inscribed in a circle, find its area. You may assume that the polygon exists. In addition, the polygon will be convex and not ...
12
votes
5answers
347 views

Identify the Conic Section

Given 5 distinct points on a two-dimensional plane, determine the type of conic section formed by the points. The output shall be one of circle, hyperbola, ellipse, or parabola. Rules The points ...
15
votes
7answers
2k views

Primes in Different Bases

Challenge: You are given a base 10 number. For each base from 10 counting down to base 2: Take the original input number as a base 10 string, and remove any digits of the number which are invalid ...
4
votes
1answer
308 views

Need help golfing Python 3 code to calculate volume & surface of spheroids in <150 bytes

I want to write a function golf(C, A) that takes the height (C = 2*c) and the width (A = 2*a) of an oblate (left image) or prolate (right image) spheroid or a sphere as parameters and returns the ...
-3
votes
1answer
148 views

Ponderous primality testing [closed]

One of my favorite algorithms was posted on Stack Overflow as an answer to What is the fastest way to generate prime number recursively?. In pseudocode: Nathan's algorithm bool isPrime(int n): ...
22
votes
36answers
2k views

Greatest Common Divisor

Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible. You may write a program or function, taking input and returning output via any of ...
-2
votes
0answers
101 views

Fastest code to find the nth Prime [duplicate]

Given input n, find the nth prime number in the shortest time possible, where a prime number is defined as having exactly two factors, i.e. 1 and itself. I will run each piece of code for 65536 ...
17
votes
2answers
694 views

Where will the cat go? (orbital mechanics)

A nearly massless cat is dropped in space (don't worry, with a space suit and everything) at the point (x, y, z) with velocity (vx, vy, vz). There is an fixed, infinitely dense planet (with volume of ...
25
votes
2answers
1k views

Approximating a special case of the Riemann Theta function

This challenge is to write fast code that can perform a computationally difficult infinite sum. Input An n by n matrix P with integer entries that are smaller than 100 in absolute value. When ...
21
votes
25answers
2k views

The plus-minus sequence

The plus-minus sequence The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the ...
27
votes
14answers
2k views

The Arithmetic Derivative

The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only ...
-4
votes
3answers
181 views

Evaluate an infinite sum [closed]

This challenge is write code that can perform an infinite sum to high precision. Task Your code should compute sum(exp(-x^2), x = -infinity..infinity) to 50 decimal places. The answer should ...
3
votes
4answers
123 views

Is this a Lucas number? [duplicate]

Write a program or function that takes an input greater than or equal to 2. It should output a truthy or falsy value corresponding to whether the input is a Lucas number or not. You may take input ...
14
votes
11answers
469 views

Ravenity of Cube Distance Numbers

Inspired by this Numberphile entry Background The cube distance numbers of an integer n are defined here as the set of integers that are x³ distance away for a given x. For a simple example, with ...
8
votes
2answers
138 views

Count rectangle intersections

The Challenge Given an arbitrary amount of rectangles, output the total count of intersections of those when drawn in a 2D plane. An intersection here is defined as a point P which is crossed by two ...
16
votes
11answers
668 views

Create an ABACABA city

Here is the 3rd ABACABA city: _ A|_| B|__| A|_|_ C|___| A|_| B|__| A|_| It is made out of the ABACABA sequence, which is basically: A (1st iteration) place B - AB repeat A - ABA (2nd iteration) ...
11
votes
2answers
319 views

Solve a Linear Equation

This challenge but with a better spec. Spec Your program will take a linear equation containing a single variable x and output the value of x. Input / Parsing The input will only contain numbers, ...
14
votes
4answers
271 views

How far from the exterior?

Take a 2D region of space divided into axis aligned unit square elements with their centers aligned at integer intervals. An edge is said to be internal if it is shared by two elements, otherwise it ...
7
votes
6answers
363 views

Generate m-sequences

Introduction Maximum-length sequences, usually known as m-sequences, are binary sequences with some interesting properties (pseudo-noise appeareance, optimal periodic autocorrelation) which make them ...
11
votes
3answers
265 views

Trilaterate your position

Introduction Imagine you are on a two dimensional cartesian plane and want to determine your position on it. You know 3 points on that plane and your distance to each of them. While it is always ...
28
votes
2answers
247 views

Addition on Elliptic Curves

Addition on Elliptic Curves Disclaimer: This does not do any justice on the rich topic of elliptic curves. It is simplified a lot. As elliptic curves recently got a lot of media attention in the ...
10
votes
6answers
947 views

On the edges of the hypercube

Your job will be to write a function or a program, that will take an integer n>0 as input and output a list of the edges of the n-dimensional hypercube. In graph theory an edge is defined as a ...
10
votes
16answers
921 views

Print the difference in the Thue-Morse sequence

Note, when I say "negate", I mean replace all ones with zeroes (i.e. a bitwise negation) The Thue-Morse sequence goes like 01101001 The way you generate it is: Start by taking 0. Negate what is ...
12
votes
1answer
197 views

Iterated Moving Average

If we have a list, say the list [9, 2, 4, 4, 5, 5, 7], we can do a moving average across it. Taking a window of say, 3 elements, each element is replaced by a window like such: [[9], [9, 2], [9, ...
13
votes
11answers
583 views

Minimum Scalar Product

Minimum Scalar Product The inspiration for this code golf problem is from Google's code jam competition. The premise behind the problem is, given the input of two vectors of varying lengths, find the ...
4
votes
2answers
167 views

Calculate the Riemann Zeta Function of a Complex Number

Introduction I found this question that was closed because it was unclear, yet it was a nice idea. I'll do my best to make this into a clear challenge. The Riemann Zeta function is a special ...
18
votes
12answers
2k views

Calculate the volume of an object

You can determine the volume of objects based on a given set of dimensions: The volume of a sphere can be determined using a single number, the radius (r) The volume of a cylinder can be determined ...
28
votes
14answers
2k views

Find the powertrain!

The winner (pretty obviously) is Dennis ♦, who used Jelly with 10 bytes! This challenge will still be up here, however results won't be taken anymore. The powertrain of a number is a concept by ...
-5
votes
4answers
163 views

Solve an algebraic expression

The Challenge Your task is to create a program that can solve an algebraic equation. Input Input will consist of a String. The string will be an equality involving the variable x, and follows the ...
7
votes
9answers
308 views

set intersection of two lists

Your goal is to compute the set intersection of two lists of integers. The intersection is defined as the unique un-ordered group of integers found at least once in both input list. Input The input ...
21
votes
15answers
783 views

Vandermonde Determinant

Given a vector of n values (x1,x2,x3,...,xn) return the determinant of the corresponding Vandermonde matrix. This determinant can be written as: Details Your program/function has to accept a list ...
4
votes
2answers
198 views

Bit Manipulator/Reader

Introduction There are often times that we have challenges which require communication of some sort (such as in team KOTH), where density of information may be more important than density of code. ...
9
votes
8answers
343 views

Pascal's Triangle as a 2-dimensional list

Create a Pascal's Triangle that is a nested list and contains zeros in the unused spots. In the output array, the numbers of Pascal's Triangle are separated by zeroes and padded by zeroes on each ...