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

learn more… | top users | synonyms

6
votes
0answers
56 views

GOLF CPU - Implement Arbitrary Precision Integer Division

This question was inspired this question and @orlp's comment and a lot of the explanation was copied from there. Write a GOLF assembly program that given two arbitrary size decimal integers a, and b ...
8
votes
1answer
158 views

An optimization version of the Hadamard problem

First, some definitions. A Hadamard matrix is a square matrix whose entries are either +1 or −1 and whose rows are mutually orthogonal. The Hadamard conjecture proposes that a Hadamard matrix of ...
1
vote
0answers
62 views

Corrupted linked list [on hold]

Suppose you are given a pointer to the head of a singly linked list. Normally each node in the list has a pointer to the next element, and the last node's pointer is Null. Unfortunately the list might ...
-1
votes
0answers
54 views

Simultaneous Equation Solver [duplicate]

Solve linear simultaneous equations with up to 26 variables (a-z). Edit: This question is similar but different to the one posed here. This question is designed to take in more natural inputs, as ...
2
votes
0answers
81 views

Num of pyramids possible with given number of bricks [closed]

I encountered this question in an interview and could not figure it out. I believe it has a dynamic programming solution but it eludes me. Given a number of bricks, output the total number of 2d ...
25
votes
10answers
816 views

Print, Increment, Decrement, Alias - Interpret Prindeal

Prindeal (pronounced prin-dee-al) is a new esoteric programming language that only has four commands: print, increment, decrement, and alias. Despite its minimalism, complex mathematical operations ...
5
votes
2answers
220 views

Laplace transform of a polynomial

Your goal is to write a program that will print out the Laplace transform of a polynomial function with integer coefficients f(x). The Laplace transform of f(x) is defined as the integral from 0 to ...
13
votes
11answers
1k views

Empty a Swimming Pool . . . With Only a Red Solo Cup

You have a swimming pool that is filled to the brim with water. You need to empty it, but you can't think of an efficient method. So you decide to use your red solo cup. You will repeatedly fill the ...
13
votes
4answers
373 views

Find the largest independent set in a high-dimensional lattice-like graph

For a given positive integer n, consider all binary strings of length 2n-1. For a given string S, let L be an array of length n which contains the count of the number of 1s in each substring of ...
25
votes
4answers
775 views

World Big Dosa​

You are a talented young chef who has just been offered the position of sous chef at the world's most prestigious Indian restaurant. You have little experience with preparing Indian cuisine, but ...
0
votes
2answers
195 views

Name a number using the Myriad System!

The Myriad System is an alternative system for naming large numbers proposed by Donald Knuth in 1981. In this system, numbers up to 999 are named as they are normally, but 1000 is not given a special ...
15
votes
10answers
1k views

Symbolic Differentiation of Polynomials

Symbolic Differentiation 1: Gone Coefishin' Task Write a program that takes in a polynomial in x from stdin (1 < deg(p) < 128) and differentiates it. The input polynomial will be a string of ...
16
votes
7answers
518 views

All your bijective base are belong to us

Background A bijective base b numeration, where b is a positive integer, is a bijective positional notation that makes use of b symbols with associated values of 1 to b. Unlike its non-bijective ...
31
votes
12answers
4k views

The Will Rogers Phenomenon

The so-called Will Rogers phenomenon describes a way to tweak statistics by raising the average in two (multi)sets when one element is moved between the two sets. As a simple example, consider the two ...
9
votes
3answers
318 views

Knödel numbers - Find Kn

Knödel Numbers The Knödel numbers are a set of sequences. Specifically, the Knödel numbers for a positive integer n are the set of composite numbers m, such that all i < m, coprime to m, satisfy ...
15
votes
13answers
500 views

Find the reference angle

This is a fairly simple question. According to this random website I found, a reference angle is the acute angle formed by the terminal side of the given angle and the x-axis. You have to write a ...
16
votes
8answers
902 views

Every Possible Cycle Length

A function (or program) which takes inputs and provides outputs can be said to have a cycle if calling the function on its own output repeatedly eventually reaches the original number. For instance, ...
6
votes
11answers
370 views

Divisor sum from prime-power factorisation

The task is to compute the divisor sum of a number given its prime factorisation. Input Two arrays (or something equivalent) of length n, one containing the prime factor and the other containing the ...
18
votes
13answers
3k views

Simpson diversity index

The Simpson index is a measure of diversity of a collection of items with duplicates. It is simply the probability of drawing two different items when picking without replacement uniformly at random. ...
17
votes
9answers
529 views

Modular Fibonacci Cycles [duplicate]

The Fibonacci sequence is a well known and famous sequence, where each successive element is the sum of the previous two. A modular Fibonacci sequence is the same, except that the addition is ...
13
votes
6answers
904 views

A determinant optimization challenge

Consider 30 by 30 Toeplitz matrices all of whose entries are 0 or 1. This challenge is a simple optimization challenge to find the matrix with the largest determinant possible. Input None Output A ...
5
votes
2answers
260 views

Conversion to Boolean satisfiability

Given a matrix M all of whose entries are 0 or 1, we want to known whether there exists a non-zero vector v with each element in {-1, 0, 1}, such that Mv = 0. An easy way to do this is just to try ...
76
votes
14answers
5k views

The Colors in Our Stars

Write a program that takes in a string or text file whose first line has the form width height and each subsequent line has the form x y intensity red green blue where: width and height may be ...
18
votes
12answers
1k views

Sum of smallest prime factors

SF(n) is a function which computes the smallest prime factor for a given number n. We'll call T(N) the sum of every SF(n) with 2 <= n <= N. T(1) = 0 (the sum is over 0 summands) T(2) = 2 (2 ...
14
votes
7answers
861 views

Find the maximum determinant for each size Toeplitz matrix

For a fixed n, consider the n by n Toeplitz matrices with entries which are either 0 or 1. The aim is to find maximum determinant over all such Toeplitz matrices. Task For each n from 1 upwards, ...
6
votes
1answer
341 views

Go south, east and north, come to the same place

There is that famous riddle: A bear walks 1 km south, 1 km east and 1 km north, and comes to the place it started from. What color is the bear? This one is very old, so I'll generalize it: A ...
-3
votes
1answer
313 views

The Miscalculator

Inspired by a post I saw on social media, your job is to create a miscalculator (aka "wrongulator"): a calculator which always outputs the wrong answer! Challenge Write a program that inputs a ...
44
votes
24answers
5k views

First code golf decathlon

Tasks All competitors try to solve the following list of 10 tasks: math Read a positive integer n from input and return the sum of the cubes of the first n non-negative integers. For input 1, ...
10
votes
2answers
259 views

Naturally linear Diophantine equations

A linear Diophantine equation in two variables is an equation of the form ax + by = c, where a, b and c are constant integers and x and y are integer variables. For many naturally occurring ...
-4
votes
2answers
176 views

Deciding if x-y is 0 or negative without using conditionals [closed]

So, My friend has come up with this interestng question, that is, given two numbers x and y deciding whether their difference: x-yis 0 or less without using any conditionals. The code should return 0 ...
5
votes
1answer
303 views

Compute 30000 Digits of Pi (π), as Fast as Possible [duplicate]

Compute 30000 digits of the mathematical constant π, with the fastest code. Implement in any computer programming language that I can run in my 64 bit Linux machine. You should provide your compiler ...
9
votes
2answers
657 views

Probabilities - how high can you go?

I previously asked a question for how to compute a probability quickly and accurately. However, evidently it was too easy as a closed form solution was given! Here is a more difficult version. This ...
23
votes
9answers
2k views

Help me carry my shopping bags

It was a warm summer evening... when my stupid car decided to break down in the middle of the road on my way back from the supermarket. I pushed it to the sideline and decided to walk home. I opened ...
8
votes
5answers
880 views

Calculate a probability exactly and quickly

[This is a partner question to Calculate a probability exactly ] This task is about writing code to compute a probability exactly and quickly. The output should be a precise probability written as a ...
26
votes
16answers
3k views

All about basic binary

Please excuse the punny title. This is a question is inspired by A Curious Property of 82000. In it, the author points out that the number 82000 is binary in base 2, 3, 4, and 5. The post then ...
20
votes
8answers
894 views

Hook length product

A Young diagram is an arrangement of boxes in left-justified rows and top-justified columns. For each box, all the spaces above it and to its left are occupied. XXXXX XXX XXX X The hook length of a ...
9
votes
3answers
485 views

Supersonic domino tilings

Task Write a program that reads three integers m, n either from STDIN or as command-line arguments, prints all possible tilings of a rectangle of dimensions m × n by 2 × 1 and 1 × 2 dominos and ...
14
votes
5answers
493 views

Determine the Dimensions of a Rotated Rectangle

This Stack Snippet draws an aliased white rectangle on a black background given parameters for its dimensions, position, angle, and the grid dimensions: <style>html ...
15
votes
7answers
2k views

Where should I put my restaurant?

You are the owner of a restaurant. You are opening in a new area in Cartesia where there is only one main road, known as the y-axis. You want to place your restaurant such that you minimize the total ...
19
votes
9answers
843 views

Calculating Collatz Cousins

Define the function f(n) for a positive integer n as follows: n / 2, if n is even 3 * n + 1, if n is odd If you repeatedly apply this function to any n greater than 0, the result always seems to ...
5
votes
1answer
182 views

Plus one sheep minus one sheep

Once upon a time long long ago...when there was no money or stocks yet, people were trading sheep. Even before (but close to) the invention of abacus, the great-grandfather of Warren Buffet decided it ...
22
votes
17answers
2k views

XOR multiplication

You goal is to implement the operation of XOR (carryless) multiplication, defined below, in as few bytes as possible. If we think of bitwise XOR (^) as binary addition without carrying 101 5 ^ ...
10
votes
9answers
740 views

Calculating distances mod N

You have been collecting data from a Advanced Collecting Device Controller™ for a long time. You check the logs, and to your horror you discover that something has gone terribly wrong: the data ...
2
votes
3answers
205 views

Calculate the first n perfect numbers [closed]

Write a program that calculates the first n perfect numbers. A perfect number is one where the sum of the factors is the original number. For example, 6 is a perfect number because 1+2+3=6. No non ...
7
votes
3answers
629 views

Matrix property X revisited (or the Joy of X)

This challenge is partly an algorithms challenge, partly an optimization challenge and partly simply a fastest code challenge. A T matrix is fully specified by its first row r and first column c. ...
15
votes
4answers
961 views

Make the largest infinity that you can!

The ordinal number system is a system with infinite numbers. A lot of infinite numbers. So many infinite numbers that it literally does not have an infinity to represent its own infiniteness. The ...
1
vote
4answers
583 views

Memory is Expensive [closed]

You are a robot. You are stranded in a small cage with weird humans wearing weird suits looking at you. Your solar panel is malfunctioning, and your energy is running out. On the wall there is a ...
10
votes
3answers
544 views

Count the number of Hankelable matrices

Background A binary Hankel matrix is a matrix with constant skew-diagonals (positive sloping diagonals) containing only 0s and 1s. E.g. a 5x5 binary Hankel matrix looks like a b c d e b c d e f c d ...
20
votes
9answers
2k views

Generate a pair of integers from a non-negative one

You should write a program or function which takes a non-negative integer N as input and outputs or returns two integers (negative, zero or positive) X and Y. Integers are meant in the mathematical ...
16
votes
16answers
1k views

Generate MathJax for the Golden Ratio Continued Fraction

In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered ...