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

learn more… | top users | synonyms

9
votes
2answers
273 views

Draw the Sierpinski Arrowhead Curve

Introduction The Sierpinski Arrowhead Curve is a curve that's limit is Sierpinski's Triangle. It first starts like this: _ / \ Then, each line is replaced with a rotated version of the first one: ...
9
votes
14answers
1k views

Do Matrix Multiplication!

In mathematics, matrix multiplication or the matrix product is a binary operation that produces a matrix from two matrices. The definition is motivated by linear equations and linear transformations ...
30
votes
31answers
3k views

Goodness Giza Golf!

A "Giza number", also colloquially known as a Timmy Number is any number where the digits represent a pyramid (A134810). For example, "12321" is a giza number because it can be visualized like this: ...
5
votes
1answer
183 views

Check if rectangles fill a rectangular space without gaps or overlaps

This challenge is based on another similar challenge. Because finding the most efficient packing of rectangles is NP-hard (that is, its solution is easy to check but hard to find), this challenge is a ...
7
votes
2answers
387 views

Manoeuvre the grid!

Briefing: You are a bot, in a 2D grid that extends infinitely in all four directions, north, south, east and west. When given a number, you must move the bot so that you get to the target number. ...
5
votes
4answers
168 views

Plot a list of numbers

Are you feeling jealousy towards Mathematica, Matlab et al. for their intricate plotting capabilities? If you answered yes, this challenge is for you! Challenge Given, via parameters or standard ...
11
votes
17answers
1k views

Find the rate of change at a point on a polynomial

Given the equation of a polynomial and an x-coordinate find the rate of change of the point at that x-coord on the curve. A polynomial is in the form: axn + axn-1 + ... + ax1 + a, where a ϵ Q and n ϵ ...
9
votes
3answers
266 views

Code golf a random orthogonal matrix

An orthogonal matrix is a square matrix with real entries whose columns and rows are orthogonal unit vectors (i.e., orthonormal vectors). This means that M^T M = I, where I is the identity matrix ...
11
votes
5answers
542 views

Solve the Laplace equation

Introduction to Numerical Mathematics This is the "Hello, World!" of PDEs (Partial Differential Equations). The Laplace or Diffusion Equation appears often in Physics, for example Heat Equation, ...
16
votes
19answers
2k views

N-dimensional Circles!

Write a program that takes two numbers as its input. The first one is the number of dimensions - 0 for a dot, 1 for a straight line, 2 for a circle, 3 for a sphere. The second number is the radius of ...
15
votes
23answers
1k views

How many integers contain a number in a specific range

The program should take input the number, the start of the range and the end of the range, and output how many integers the number appears between the start and end of the range, inclusive. Both ...
13
votes
2answers
992 views

Primes with a twist

Note: this is heavily inspired by this question. Task: Your task is to generate the nth prime, when each character of your program is repeated n times in place. Let's say your program is: Derp ...
30
votes
28answers
4k views

Count without 3

Background When I was in elementary school, we used to play a game in math class that goes as follows. All kids sit in a big circle and take turns counting, starting from 1. However, the following ...
10
votes
5answers
260 views

How many significant figures?

Given a number as input, determine how many significant figures it has. This number will should be taken as a string because you have to do some special formatting. You'll see what I mean soon (I ...
10
votes
1answer
273 views

The Switching Sequence

Intro The Switching sequence is defined like so: Start with n people standing in a circle (6 for this example). 1 2 6 3 5 4 Starting from person 1, the person that is to the left of the "...
20
votes
8answers
686 views

Generate a modulo rosace

The cool stuff The following rosace can help calculate numbers modulo 7. In order to do that, you must start at 0 and turn clockwise a number of steps given by the first digit. Then, for each ...
15
votes
8answers
609 views

Bailey–Borwein–Plouffe Iterations

Bailey–Borwein–Plouffe Iterations We've seen a few pi challenges on PPCG, but none that specifically dictate the algorithm you should be using. I'd like to see implementations of the Bailey–Borwein–...
5
votes
7answers
400 views

Approximate arcsinc

The goal is simple: Output a nonzero real solution x to the equation sin(x) = -mx, given input m, in the fewest number of bytes. Specifications: Your answer must be correct to 3 significant figures....
5
votes
2answers
231 views

Print the n-th digit of pi [duplicate]

Task Given an input n, calculate the n-th decimal digit of pi Rules Answer can be a full program or a function. Input must be taken from stdin or from function arguments. Output must be either sent ...
25
votes
9answers
2k views

Calculate the permanent as quickly as possible

The challenge is to write the fastest code possible for computing the permanent of a matrix. The permanent of an n-by-n matrix A = (ai,j) is defined as Here S_n represents the set of all ...
13
votes
29answers
790 views

Print the tetration

Tetration, represented as a^^b, is repeated exponentiation. For example, 2^^3 is 2^2^2, which is 16. Given two numbers a and b, print a^^b. Test cases 1 2 -> 1 2 2 -> 4 5 2 -> 3125 3 3 -&...
16
votes
12answers
481 views

Goldbach partitions

The Goldbach conjecture states that every even number greater than two can be expressed as the sum of two primes. For example, 4 = 2 + 2 6 = 3 + 3 8 = 5 + 3 However, once we get to 10 something ...
77
votes
23answers
5k views

Does the code terminate?

This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An ...
11
votes
24answers
668 views

Find the maximum deviation

This problem is "inspired" from a question that was originally asked on Quora (not for code golfing). I just want to make it a challenge for you guys (and my first problem submission here). Given an ...
8
votes
15answers
737 views

Maximal number of regions obtained by joining n points around a circle by straight lines

Let's define f(n) as the aximal number of regions obtained by joining n points around a circle by straight lines. For example, two points would split the circle into two pieces, three into four, like ...
21
votes
20answers
5k views

A penny saved is a penny

...counted! You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values. Your challenge is to output the number of possible ...
14
votes
11answers
2k views

Codegolf the permanent

The challenge is to write codegolf for the permanent of a matrix. The permanent of an n-by-n matrix A = (ai,j) is defined as Here S_n represents the set of all permutations of [1, n]. As an ...
16
votes
15answers
2k views

Compute the Eulerian number

The Eulerian number A(n, m) is the number of permutations of [1, 2, ..., n] in which exactly m elements are greater than the previous element. These are also called rises. For example, if n = 3, there ...
6
votes
2answers
269 views

String Calculator

Assume you're writing in one method, (or whatever you call them) with 3 inputs: the first string, a character that contains a +, - or * symbol, and the second string. Example in Java: public String ...
24
votes
23answers
3k views

Compute the kangaroo sequence

Backstory Disclaimer: May contain made up information about kangaroos. Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they ...
9
votes
3answers
376 views

Natural Pi #1 - Sand

Goal Generate (N) random line segments of uniform length (l), check if they cross the equidistant (t) parallel lines. Simulation What are we simulating? Buffon's needle. Smooth out the sand in your ...
12
votes
19answers
1k views

Division of not so little numbers

Write a program or function that takes in positive integers a, b and c, and prints or returns a/b to c decimal places, using the operations +-*/% [add, subtract, multiply, divide, modulate] on the ...
18
votes
14answers
1k views

Terminating, Purely Periodic, or Eventually Periodic?

Introduction A decimal is terminating if it has a finite number of decimal digits. For example, 0.4 (2/5) is terminating because it has one decimal digit. A decimal is purely periodic if it has an ...
-9
votes
21answers
293 views

Sum the unique numbers in a list

For this challenge, the objective is to take a list of integers, and output the sum of every unique integer in that list, i.e. count multiples of the same integer only once. Your input will be a ...
8
votes
5answers
268 views

It's time to make a histogram

Your task is to make a histogram given a sample of arbitrary size. Input A float array or any other reasonable form of input with an arbitrary number of elements. Output The histogram; more to ...
7
votes
0answers
159 views

Rationalise the Denominator [closed]

Challenge Given a fraction with a surd (an irrational number) as the denominator, output the rationalised fraction. Rationalising the Denominator To rationalise the denominator, what you have to do ...
36
votes
17answers
3k views

Natural Pi #0 - Rock

Goal Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns sqrt(6 * N / #coprime). TL;DR These challenges are simulations of ...
3
votes
4answers
312 views

Find the intersection point of a plane and ray

Given a ray with a point and a vector and a plane with a point and a normal vector to the plane. You have to find the intersection point of the plane and the ray.. So your job if you choose to accept ...
3
votes
16answers
270 views

How much will this cost?

Given N items (0 < N <= 50) with prices (which are always integers) P0 ... PN-1 and given amounts of each item A0 ... AN-1, determine how much the total cost will be. Examples N: 2 P0: 2 P1: 3 ...
18
votes
19answers
784 views

Natural construction

The natural numbers including 0 are formally defined as sets, in the following way: Number 0 is defined as the empty set, {} For n ≥ 0, number n+1 is defined as n ∪ {n}. As a consequence, n = {0, 1, ...
21
votes
28answers
1k views

Least Common Multiple

The least common multiple of a set of positive integers A is the smallest postive integer B such that, for each k in A, there exists a positive integer n such that k*n = B. Given at least two ...
42
votes
18answers
2k views

Dennis numbers 2.0

PPCG user and elected mod, @Dennis just became the second ever user to earn over 100k rep! This is a totally original idea, that I did not get from anybody else, but let's make a challenge based off ...
17
votes
19answers
1k views

Compute the Mertens function

Given a positive integer n, compute the value of the Mertens function M(n) where and μ(k) is the Möbius function where μ(k) = 1 if k has an even number of distinct prime factors, -1 if k has an odd ...
8
votes
1answer
187 views

Perform Dempster's Rule of Combination

Crash Course on DST Dempster–Shafer theory (DST) provides a method to combine various sources of evidence to form a belief. Given a list of possible statement (one of which is the true answer), each ...
21
votes
9answers
2k views

The Solitude of Prime Numbers

Recently I read the novel "The Solitude of Prime Numbers" where the main characters are somewhat compared to twin prime numbers ("always together, but never touching"). A twin prime is a prime ...
20
votes
6answers
871 views

Unlucky Numbers!

Things to know: First, lucky numbers. Lucky numbers are generated like so: Take all the natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20... Then, remove each ...
19
votes
22answers
940 views

The Base in the mix

Input: A list/array of integers for which each item is in the range of 2-36. Output: The sum of the integers (as base 10), where each next integer is in the base of the previous value (starting with ...
22
votes
11answers
2k views

The Decanting Problem

Given N decanters (0 < N < 10) with that can hold C0 ... CN-1 liters (0 < C < 50) and a goal G liters, please determine if it is possible to reach that goal using only the following ...
6
votes
3answers
271 views

Alexa and the Tea Plantation

Hey guys, first time poster here. I went on Coderoulette recently and some guy posted this question. I looked around online but it doesn't seem to be anywhere. I figured I would post it here for ...
32
votes
19answers
4k views

Compute the Carmichael function

Task description In number theory, the Carmichael function λ takes a positive integer n and returns the least positive integer k so that the k-th power of each integer coprime to n equals 1 modulo n. ...