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

learn more… | top users | synonyms

0
votes
0answers
101 views

Output Pi - Alphanumeric [closed]

Output π up to at least 5 digits of precision. But no non-alphanumeric characters (each one is a 5 byte penalty), and the lowest bytes wins! Have Fun! You can play dirty (hex, charcodes, etc.) and ...
10
votes
2answers
188 views

Computing truncated digits sums of powers of pi

Given a positive integer n output the sum of the first n decimal digits of the fractional part of πn. Example input and outputs: 1 → 1 2 → 14 3 → ...
17
votes
6answers
2k views

Chinese Remainder Theorem

The Chinese Remainder Theorem tells us that we can always find a number that produces any required remainders under different prime moduli. Your goal is to write code to output such a number in ...
14
votes
0answers
187 views

Prime polynomials

Given a polynomial, determine whether it's prime. A polynomial is ax^n + bx^(n-1) + ... + dx^3 + ex^2 + fx + g, where each term is a constant number (the coefficient) multiplied by a nonnegative ...
48
votes
2answers
3k views

Quiche Lorraine

Since it was Pi day recently, I have noticed a number of challenges that ask you to calculate pi. Of course, a quiche lorraine is not quite a pie (you can claim a Bonus Score¹ of +1 if you guessed ...
6
votes
3answers
516 views

Finding Collatz-like rules with many loops

This code-challenge is related to the code-golf question Analyzing Collatz-like sequences but the goal is quite different here. If you are familiar with Collatz-like sequences you can skip to the ...
10
votes
5answers
852 views

Transmit Pi… precisely

Following on from Monte Carlo estimator of Pi this challenge is to produce the shortest code for the constant Pi. Except here your code must output consecutive digits of pi forever. This is code ...
5
votes
7answers
606 views

Digit sum of powers in bases

You should write a program or function which outputs or returns the sum of the digits in base b representation of the first n natural power of a in ascending order. Example for a = 2, b = 3 and n = ...
8
votes
2answers
326 views

Fastest way to compute order of magnitude in x86 assembly

The task is simple: write assembly that computes the order of magnitude of an integer using as few clock cycles as possible. Order of magnitude is defined as log10, not log2. The range of valid ...
13
votes
1answer
155 views

Analyzing Collatz-like sequences

We define a Collatz-like sequence s with 4 positive integers: n starting value d > 1 divisor m > 1 multiplier i increment (In the original Collatz sequence d = 2 m = 3 and i = 1.) Given ...
1
vote
0answers
62 views

Weighted distribution [closed]

Your code should: Take in a set of values, each value should be given a weighted percentage. In a loop, up to 1000 iterations, each value should be incremented by one each time it is returned, ...
-1
votes
1answer
212 views

Find the inverse of a matrix

Write a full program to calculate the inverse of a 4-by-4 matrix. Rules The sixteen values of the initial matrix must be hard-coded to variables, as follows: _ _ |a b c d| |e f g h| |i j k l| ...
0
votes
0answers
165 views

Rise and Shine! [duplicate]

Challenge The challenge is to create a program which takes a date, a latitude, and a longitude, and prints the time of the sunrise on that date for the given location. The program must work for any ...
5
votes
3answers
571 views

Solve a 2x2 Eigensystem

For those with a little linear algebra background, the challenge is as simple as this: determine the eigenvalues and eigenvectors of a given complex 2x2 matrix. You may skip ahead to The Challenge for ...
3
votes
3answers
526 views

Generate all 4-perfect numbers

Your program or function should output all the 36 4-perfect numbers in increasing order separated by newlines. An n positive integer is a k-perfect number (multiply perfect number) if the sum of its ...
9
votes
1answer
451 views

Bad News, Someone

In the Futurama episode The Prisoner of Benda members of the crew swap bodies with each other, with the catch that no pair of bodies can have their minds swapped more than once. Challenge Write a ...
12
votes
1answer
570 views

Sharing pizza fairly

The difficulty with sharing pizza with friends is that it is hard to make sure that everyone gets the same amount of pepperoni on their slice. So, your task is to decide how to fairly slice a pizza so ...
9
votes
11answers
648 views

Find pairs of numbers with a particular LCM and GCD

I was working on a math question with a friend of mine, and we decided to write a script that finds the answer. The original question is as follows: The difference of two natural numbers is 2010 ...
13
votes
3answers
1k views

Computer: you do the math

This challenge is partly an algorithms challenge, involves some math and is partly simply a fastest code challenge. For some positive integer n, consider a uniformly random string of 1s and 0s of ...
5
votes
2answers
702 views

Coding a recursive function for highest possible input

Challenge You are given the following function:- which is the same as:- with the base cases q(r, b, L) = 1 whenever r ≤ L, q(r, 0, L) = 0, if r > L and q(r, 0, L) = 1, if r ≤ L. Your task is to ...
2
votes
4answers
423 views

Use threes to count the threes!

Write a program or function that takes two numbers - x>3 and n>0 - as input, and finds all possible bases b where the digit 3 appears at least n times in (x in base b). Input and output may be ...
20
votes
22answers
2k views

Shortest Minmod Function

The minmod function is a variant of the familiar min, which appears in slope-limiting high-resolution schemes for partial differential equations. Given a number of slopes, it picks out the flattest ...
5
votes
6answers
341 views

Mobius inversion

Your goal is to implement Möbius inversion, a linear operation on a sequence of numbers that is used in combinatorics and number theory. Fewest bytes wins. What is Möbius inversion? Given a (finite) ...
5
votes
4answers
568 views

Shortest program to split special array

Background Imagine, you have a big array A, which is mostly zeroes, but contains a short subarray B which has only strictly positive entries. For instance: | A | [0 0 0 ...
3
votes
8answers
930 views

Wait, but what's e^N?

Objective: The objective is to calculate e^N for some real or imaginary N (e.g. 2, -3i, 0.7, 2.5i, but not 3+2i). This is code golf, so, shortest code (in bytes) wins. So, for example: N = 3, e^N ...
11
votes
8answers
753 views

Balanced Ternary Converter

Credits for the challenge idea go to @AndrewPiliser. His original proposal in the sandbox was abandoned and since he has not been active here for several months, I have taken over the challenge. ...
14
votes
27answers
4k views

Find i^n, given n

The Challenge In as few characters as possible, find the value of i^n, given n, a positive integer greater than 0. This should be outputted as a String. For those that don't know, i is defined such ...
0
votes
1answer
124 views

CSS attribute selector efficient “greater than selector” code [closed]

The goal is to find a way better than the current best known way of encoding the index of a child HTML element, so that encoded indices have the following property. if (index_i >= index_p) { ...
9
votes
3answers
427 views

Print the intersection of sequences

Sequences You are given four number sequences, numbered 1 through 4. OEIS The location of 0's when the natural numbers are listed in binary. Here's an example of how to calculate the sequence: ...
10
votes
5answers
1k views

Calculate the Delacorte Number of a square

Challenge: implement calculation of a Delacorte Number in any language. Shortest code wins. For a given square matrix of distinct integers 1..n² (possible side length n at least between 3 and 27), ...
4
votes
1answer
302 views

Evaluate CDF of Student-t distribution

The goal of this codegolf is evaluating the cumulative distribution function of the student-t probability distribution. This is not trivial since there is no closed form and the function is dependent ...
8
votes
1answer
455 views

WinAli - Virtual CPU for understanding assembly language

WinAli is a model assembler for Windows. It emulates a real CPU and is meant to help students learning and understanding the Assembly language. German Wikipedia article: ...
11
votes
4answers
877 views

Convert x-illion into standard form

Given a string, consisting of a prefix and then "illion", convert this number into standard form. For example: "million" -> 10^6 "trillion" -> 10^12 "quattuordecillion" -> 10^45 The ...
20
votes
1answer
611 views

Can you hear me now?

Background You are a rich executive of a software empire. Your time is worth a lot of money. As such, you must always travel in the most efficient route possible. However, as an executive, you spend ...
1
vote
1answer
270 views

Find a representative submatrix

You have a matrix of size m x n. Each cell in the matrix has a uniformly random integer value v, where 0 ≤ v < i, and i ≤ (m x n). (Meaning, the matrix contains a maximum of m x n distinct values, ...
0
votes
2answers
89 views

Approximated (unsorted) square from a set of values [closed]

So a colleaque came with this problem lately and I want to challange you to solve the problem in the code-golf style, shortest solution in any language wins. The Problem: Given is a random set of ...
5
votes
2answers
639 views

Draw a Golden Spiral!

Given a number n, you must output a golden spiral with the number of quarter turns being n. The spiral must be completely black and the background must be completely white. This must be output as a ...
8
votes
8answers
623 views

Verify Magic Square

A magic square is a square array of numbers with side n consisting of the distinct positive integers 1, 2, ..., n² arranged such that the sum of the n numbers in any horizontal, vertical, or main ...
6
votes
3answers
521 views

Riemann Series Theorem

The Riemann series theorem states that the terms of a conditionally convergent series can be permutated such that the resulting series converges to an arbitrary value. The Challenge Write a program ...
1
vote
1answer
248 views

Chotchkies Restaurant [duplicate]

Because there isn't enough xkcd on PPCG... Challenge The challenge is the same as above - given a menu and a total price, you need to find what the customer ordered. The menu will be supplied as ...
12
votes
1answer
418 views

Factor a polynomial over a finite field or the integers

Without using any built-in factoring/polynomial functions, factor a polynomial completely into irreducibles over the integers or a finite field. Input Your program/function will receive some prime ...
14
votes
8answers
626 views

Tetrahedron Surface Area

The challenge This challenge is very straightforward. Given four 3-dimensional points, calculate the surface area of the tetrahedron that they form. This is code-golf, so shortest code wins. Standard ...
6
votes
7answers
584 views

Find the simplest value between two values

Goal Your goal is to find the simplest value in an open interval. In other words, given two values a,b with a<b, output the simplest x with a<x<b. This is a code golf, so fewest bytes wins. ...
3
votes
3answers
155 views

Convert number bases [duplicate]

What your function must do: be as short (in bytes) as possible take 3 inputs that are strings: number , fromdigits, todigits assume no digit is repeated in fromdigits or todigits assume fromdigit and ...
7
votes
3answers
568 views

Help me with trigonometry!

Thank you guys so much for your help with calculus. Now I need some help with my upcoming trigonometry test. On the test, I'll need to simplify expressions. I’ll be given input like 4sin(x)/(2cos(x)) ...
7
votes
20answers
1k views

Minimum excluded number

This is intended to be an easy, bite-size code-golf. The mex (minimal excluded number) of a finite collection of numbers is the smallest non-negative integer 0, 1, 2, 3, 4, ... that does not appear ...
5
votes
8answers
403 views

Subdivide-Sum Sequence

Consider the digits of any integral base above one, listed in order. Subdivide them exactly in half repeatedly until every chunk of digits has odd length: Base Digits Subdivided Digit ...
21
votes
14answers
2k views

Un-round fractions

When you convert a fraction to a decimal number and you want to store that number, you often have to round it, because you only want to use a certain amount of memory. Let's say you can only store 5 ...
45
votes
10answers
8k views

Little Chandler is sad. Draw him a cloud to cheer him up

Little Chandler is sad. Draw him a cloud to cheer him up. Note: Drawing a cloud won't actually cheer him up. A circle can be defined as a 3-tuple (x,y,r) where x is the x position of the circle on a ...
11
votes
5answers
1k views

It’s time to do the math

Introduction This is one of my favorite math puzzles. Given a digit (say 3) and the number of times to use that digit (say 5), generate 10 expressions which result to 1, 2, 3, 4, 5, 6, 7, 8, 9 and ...