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

learn more… | top users | synonyms

13
votes
1answer
388 views

Multiply with restricted operations

Goal Your goal is to multiply two numbers using only a very limited set of arithmetic operations and variable assignment. Addition x,y -> x+y Reciprocal x -> 1/x (not division x,y -> ...
8
votes
5answers
781 views

Implement an 8 bit adder

The Challenge Implement a function which accepts two integers whose values range from 0 - 255 and returns the sum of those integers mod 256. You may only use bitwise negation (~), bitwise or (|), bit ...
12
votes
7answers
387 views

Find the maximum operation

The challenge is to find the maximum number you can get from a list of integer using basic arithmetic operators (addition, substraction, multiplication, unary negation) Input A list of integers ...
8
votes
9answers
632 views

Multiply Quaternions

Write a named function or program that computes the quaternion product of two quaternions. Use as few bytes as possible. Quaternions Quaternions are an extension of the real numbers that further ...
4
votes
2answers
444 views

Another Euler Brick in the Wall

A Euler Brick is a cuboid where the length of all the edges are integers and all of the diagonals of the faces are integers as well. All sides must also be different. Your program has to find as ...
10
votes
6answers
520 views

Given r and n, find first n numbers of x where moving first digit of x to last gives x/r = y

Objective Given input r and n find the first n natural numbers x such that if we rotate the first digit to the last place we obtain x/r. You may assume that 2 <= r <= 9 and 1 <= n <= ...
7
votes
8answers
459 views

Implement bit-wise matrix multiplication

The MMIX architecture is a fairly simple big-endian RISC design. It has a couple of interesting features, one of them is the MXOR instruction, which is what you should implement. The MXOR instruction ...
14
votes
13answers
1k views

Display a tally (in varying bases)

Tallying is a simple counting system that works in base 5. There are various different tallying systems used around the world, but the one that is used in most English-speaking countries is perhaps ...
-4
votes
3answers
207 views

Convert to uppercase and lowercase without branching and comparisons

Write two functions/programs which take an ASCII code of character (8-bit unsigned integer) and one of them converts char to uppercase and other to lowercase. That is, they must be equivalent to ...
33
votes
23answers
7k views

Find the Smoothest Number

Your challenge is to find the smoothest number over a given range. In other words, find the number whose greatest prime factor is the smallest. A smooth number is one whose largest prime factor is ...
12
votes
3answers
722 views

Expression that equals its length

Given a number, find an expression in words equaling that number, with a length of that number. Thus, to an input of 15, you might output sixteen minus one, which has fifteen characters (not counting ...
0
votes
0answers
13 views

Find mathematical art [migrated]

How can I get enough reputation to be able to actually post an answer here?! It seems that I need 10 reputation to answer the one question that I really want to. I have some awesome answers to the ...
3
votes
6answers
864 views

Solve quadratic equation using only 3 variables and arithmetic

Write function which solves equation of degree less than or equal to 2 (ax^2 + bx + c = 0). Input Function should get 3 parameters - floating point numbers which are coefficients of this equation. ...
5
votes
2answers
591 views

The distance between circles

Imagine you are given two lists of numbers which are to be interpreted as points on a circle of circumference 1000. Let us say circleA = [10, 24, 44, 175, 321, 579, 618, 841, 871, 979] circleB = ...
4
votes
9answers
824 views

Stack a random number of cups into a perfect two dimensional pyramid (triangle)

You are given a certain number of cups (n). You are tasked with stacking these cups into a pyramid, with each row having one more cup than the row above it. The number you are given may or may not be ...
10
votes
1answer
220 views

Primality Testing in Manufactoria

Background Manufactoria is a game about programming. The player must use a form of two-dimensional programming language to complete tasks. If you've never heard of it, the easiest way to learn is to ...
10
votes
7answers
763 views

is_gaussian_prime(z)?

Task Write a function that accepts two integers a,b that represent the Gaussian integer z = a+ib (complex number). The program must return true or false depending on whether a+ib is a Gaussian prime ...
1
vote
0answers
96 views

Push Button Probabilities [duplicate]

The Challenge The challenge is that I have a standard mechanical push button lock and you need to find out every possible code that could unlock it. With a standard mechanical push button lock you ...
8
votes
5answers
699 views

Raise to the Power

Challenge Challenge is writing a program that takes a positive numbers a and a nonzero number b and outputs a^b (a raised to the power b). You can only use + - * / abs() as mathematical ...
3
votes
1answer
156 views

Calculate the Riemann Zeta Function [closed]

Calculate the Riemann zeta function to the maximum primitive precision in your language (for C-family, that would be double or long double, var in JS, etc.) No need for BigDecimal or the like unless ...
10
votes
7answers
512 views

Molar masses of compounds

Task Write a program that takes in a compound made solely of elements with an atomic number less than or equal to 92 (Uranium), and outputs the molar mass of the compound in grams/mole. Rules and ...
268
votes
56answers
66k views

Tweetable Mathematical Art

Integer math can generate amazing patterns when laid out over a grid. Even the most basic functions can yield stunningly elaborate designs! Your challenge Write 3 Tweetable (meaning 140 characters ...
1
vote
5answers
312 views

Modular exponentiation using only addition and subtraction

The challenge In the least number of source code characters, in a language of your choosing, devise a function which raises base a to power b, modulo m, using purely integer arithmetic, where a, b, ...
14
votes
3answers
517 views

Find the shortest bracket numbers

Bracket numbers provide a simple way to express large integers using only left bracket, space, and right bracket ([ ]). A bracket number is defined as a string of one or more pairs of matching ...
11
votes
26answers
2k views

Integer square root of integer

Problem: In your choice of language, write the shortest function that returns the floor of the square root of an unsigned 64-bit integer. Test cases: Your function must work correctly for all ...
3
votes
10answers
497 views

Base-2 integer logarithm of 64-bit unsigned integer

Problem: In your choice of language, write the shortest function that returns the floor of the base-2 logarithm of an unsigned 64-bit integer, or –1 if passed a 0. (Note: This means the return type ...
16
votes
4answers
589 views

Three-pointer! But what kind?

From http://en.wikipedia.org/wiki/Triangle: Write a program that takes three 2d coordinate tuples (Cartesian), and classifies what shape these three points describe. In almost all cases these ...
11
votes
2answers
391 views

place vials in your centrifuge

This question originates in this reddit thread by reddit user taho_teg but it is expanded to a more general 'puzzle'. You have a centrifuge with 24 holes for the vials uniformly distributed in a ...
2
votes
1answer
319 views

Recursive Mathematical Puzzle from a high school contest

The problem appeared on the 2013 SJCNY High School Programming Contest. It was the last question in the set of problems and no team produced a correct answer during the 2.5 hours they had to work on ...
7
votes
8answers
1k views

Write an IBAN validator

Write a program (the body of the function is enough) that accepts a string of alphanumeric characters and validates it according to ISO 13616:2007. The algorithm for validation is (source: wikipedia ...
1
vote
6answers
134 views

Generate the group table for Z_n

Groups are a widely used structure in Mathematics, and have applications in Computer Science. This code challenge is about the fewest # of characters to create a group table for the additive group ...
1
vote
3answers
294 views

Solving Systems of Equations using Cramer's Rule

Create an algorithm that uses Cramer's Rule (with determinants of matrices) to solve for the solutions of a system of linear equations. The code should work for an "n" number of variables. You may ...
2
votes
0answers
103 views

Write program which finds shortest expression for number [duplicate]

Write program which finds shortest expression for big integer. Expression may consist of + - * / ^ ! ( ) operations. ! stands for factorial, ^ - exponentiation, / - rational division. Number itself ...
4
votes
0answers
253 views

Write a FAST word equation solver [duplicate]

This question is similar to Write a word equation solver by David Frank but different in three important ways: (1) David asked for just the first solution found, and I am asking for all the solutions. ...
8
votes
3answers
556 views

Calculate to how many cubes one cube can be cut

Imagine some cube which we can cut into smaller cubes without remaining pieces. Find to how many cubes a cube can be cut. For example, a cube can be cut into 8, 27 (obviously 3rd powers of integers) ...
11
votes
9answers
2k views

Write program which verifies Erdős–Straus conjecture

Write program, which verifies Erdős–Straus conjecture. Program should take as input one integern (3 <= n <= 1 000 000) and print triple of integers satisfying identity 4/n = 1/x + 1/y + 1/z, 0 ...
5
votes
5answers
449 views

Permutation Numbering

The Challenge For a given set of n integers, write a program which will output its lexicographic index. The Rules The input must only be a set of unique non-negative integers separated by spaces. ...
18
votes
13answers
1k views

Khinchin's constant to as many decimal places as possible in 64 bytes or less

Khinchin's constant is a curious mathematical constant that, according to Wolfram MathWold, is "notoriously difficult to calculate to high precision". Here it is to 100 digits: ...
18
votes
5answers
4k views

Shortest expression for {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}

Given list of integers {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}. For those who interested these numbers are used in weekday calculation. Weekday = (m[n] + d + y + y>>2 + y/400 - y/100) % 7;, where ...
6
votes
5answers
478 views

Output nth term in Catalan type sequence

Given a number, starting with 1, create new numbers (children) by taking the last digit, n, and concatenating 1 through n+1. This seems to be a much better explanation of the sequence A071159. ...
3
votes
4answers
400 views

Difference of expressions when evaluated in different orders

We all know the standard order of operations for math functions (PEMDAS), but what if we instead evaluated expressions left-to-right? The Challenge Given a string through standard input or through ...
0
votes
1answer
283 views

Solve this math problem in smallest amount of code [closed]

Here I found a cool math problem. I thought you could write some golfed code to compute all answers between x and x.(there is an infinite amount). Problem: Once upon a time, and old lady went to sell ...
5
votes
5answers
459 views

Operations on Sets

Note: I have accepted an answer, but I'm willing to accept a better answer if it comes. Write a program that computes operations on sets. You may take input either from standard input or from command ...
48
votes
14answers
7k views

“Disprove” Fermat's Last Theorem

Write a program, in the language of your choice, that appears to successfully find a counterexample to Fermat's Last Theorem. That is, find integers a, b, c > 0 and n > 2 such that an + bn = cn. Of ...
3
votes
1answer
222 views

Finding internal rate of return (IRR)

In investing, internal rate of return (IRR), the continuously compounded rate of return economically equivalent to a specified series of cashflows, is often a valuable concept. Your challenge is to ...
4
votes
2answers
624 views

Longest mathematical expression in a grid

Given a grid which contains these signs: 0..9, x, =, write the fastest code that outputs the longest string of connected (horizontally, vertically, and diagonally adjacent), distinct cells which is a ...
15
votes
7answers
1k views

Write a word equation solver

Introduction Consider the following example: CODE + GOLF —————— GREAT This is an equation where each letter represents a decimal digit and the words represent natural numbers (similar letters ...
22
votes
13answers
3k views

Calculate `n % 12`

Calculate n modulo 12 for an unsigned 32 bit integer. The Rules: Must work for all n between 0 and 23. Other numbers optional. Must only use any of the operators +-*, ~&^| or <<, ...
28
votes
7answers
2k views

Newtons Method by Recursive Quines

Newtons Method by Recursively Generating Code Your task is to calculate the square root of 2 using Newton's Method - with a slight twist. Your program is to calculate an iteration using Newton's ...
46
votes
9answers
3k views

Help me with differential calculus!

I love programming and know every language, but I suck at math. Unfortunately, my school requires that computers students must take a year of calculus. There's a test next week, and I don't know any ...