Questions tagged [arithmetic]

Challenges related to elementary arithmetic.

Filter by
Sorted by
Tagged with
43
votes
41answers
8k views

Shift right by half a bit

The challenge is to implement a program or function (subsequently referred to as "program") that takes a nonnegative integer \$n\$ as input and returns \$n\over\sqrt{2}\$ (the input divided by the ...
5
votes
15answers
3k views

Move my liquid to make me equal

You are given 4 positive integers: volume of the first container (v1), volume of the second container (v2), volume of the liquid ...
8
votes
4answers
344 views

Play flip--flop

Flip flop is a memory / arithmetic game that I played in high school. Some number of players stand in a circle. The players take turns. On the nth turn, the current ...
28
votes
13answers
3k views

Who's next to me in the queue?

Problem 4 in the 2019 BMO, Round 1 describes the following setup: There are \$2019\$ penguins waddling towards their favourite restaurant. As the penguins arrive, they are handed tickets numbered ...
17
votes
74answers
4k views

Average Two Letters

Introduction Every letter in the English alphabet can be represented as an ASCII code. For example, a is 97, and ...
2
votes
0answers
58 views

Spreadsheet Columns [duplicate]

Spreadsheet Columns In most spreadsheet programs, columns go A, B, C, ... ...
16
votes
43answers
3k views

Find the percentage

We haven't had any nice, easy challenges in a while, so here we go. Given a list of integers each greater than \$0\$ and an index as input, output the percentage of the item at the given index of the ...
44
votes
26answers
8k views

Random point on a sphere

The Challenge Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction. This is equivalent to a random point on ...
21
votes
12answers
2k views

Calculate Landau's function

Landau's function \$g(n)\$ (OEIS A000793) gives the maximum order of an element of the symmetric group \$S_n\$. Here, the order of a permutation \$\pi\$ is the smallest positive integer \$k\$ such ...
21
votes
4answers
493 views

Compute height of Bowl Pile

Bowl Pile Height The goal of this puzzle is to compute the height of a stack of bowls. A bowl is defined to be a radially symmetric device without thickness. Its silhouette shape is an even ...
21
votes
26answers
2k views

Start from ones

Given a strictly positive integer n, follow these steps: Create an array A with n 1s. If A only has one element, terminate. Otherwise, starting from the first element, replace each pair of A with its ...
22
votes
14answers
6k views

Look mom! I made my own (Base 10) numeral system! [closed]

We've all done it, well, maybe not, but making your own alien language and numbering system is a staple of especially fantasy writing, but is mostly just a fun activity. The task is simple, take two ...
12
votes
5answers
917 views

Does this addition pyramid puzzle have a unique solution?

Given an addition pyramid \$P\$, determine whether it can be solved. An addition pyramid consists of layers, each having one number less than the one below it. Layer \$i\$ is symbolized as \$P_i\$. \$...
71
votes
5answers
8k views

Machine Learning Golf: Multiplication

I'd like to propose a different kind of golfing challenge to this community: (Artificial) Neural Networks are very popular machine learning models that can be designed and trained to approximate any ...
22
votes
6answers
1k views

Subtract the Folded Matrix

Challenge: Given an NxN matrix where \$N\geq2\$ and one of eight distinct 'folding options', output a 2D array/list with the subtracted values. The eight folding options are: left-to-right; right-to-...
6
votes
12answers
320 views

Probabilistic approach puzzle

A few hours earlier, I got this puzzle: Suppose, you toss a coin n times, then what is the probability of getting m number of heads? ( where m belongs to the set of all prime numbers) For instance,...
51
votes
57answers
6k views

Multiplicative persistence

Multiplicative Persistence Multiply all the digits in a number Repeat until you have a single digit left As explained by Numberphile: Numberphile "What's special about 277777788888899?" Numberphile ...
35
votes
5answers
8k views

Historical difference between `/` and `÷` in mathematical expressions

Introduction: Inspired by a discussion that is already going on for many years regarding the expression \$6÷2(1+2)\$. With the expression \$6÷2(1+2)\$, mathematicians will quickly see that ...
19
votes
15answers
1k views

Spot all (anti)diagonals with duplicated values

Challenge: Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers. So if we have a matrix like this: ...
1
vote
2answers
234 views

Work out \$x^y\$ using only addition and subtraction [duplicate]

The challenge is to implement a function or program that takes two numbers, \$x\$ and \$y\$ and return the result of \$x^y\$. The program cannot use any other mathematical operation other than \$+\$ ...
2
votes
3answers
176 views

All the digisibles [duplicate]

A natural number (written in the decimal base) is qualified as digisible if and only if it fulfills the following 3 conditions: none of its digits is zero, all the digits that compose it are ...
13
votes
25answers
1k views

Standardize the Samples (Compute the z-Score)

Given a list of floating point numbers, standardize it. Details A list \$x_1,x_2,\ldots,x_n\$ is standardized if the mean of all values is 0, and the standard deviation is 1. One way to compute this ...
13
votes
19answers
3k views

How much candy can you eat?

Credit to Geobits in TNB for the idea A post without sufficient detail recently posited an interesting game: 2 children sit in front of an array of candy. Each piece of candy is numbered 1 to ...
-3
votes
6answers
163 views

Measuring Mountains [duplicate]

Sum-It is a language I created (quite late) for the Language Design Contest in TNB, for which the theme was "Range". Naturally I interpreted this as "Mountain Range" and created a language about ...
21
votes
38answers
2k views

Given an input, print all exponents where the base and power sum to the input

So this is my first challenge on this site. The challenge is to take in an input integer \$n\$, which will be positive, and print, in ascending order (\$1\$ to \$n\$, including n), the output of \$i^{...
22
votes
14answers
1k views

Dirichlet Convolution

The Dirichlet convolution is a special kind of convolution that appears as a very useful tool in number theory. It operates on the set of arithmetic functions. Challenge Given two arithmetic ...
23
votes
32answers
4k views

Strange Addition

Challenge Calculate the strange sum of two natural numbers (also known as lunar addition): Given \$A=...a_2 a_1 a_0\$ and \$B=... b_2 b_1 b_0\$ two natural numbers written in the decimal base, the ...
19
votes
20answers
2k views

The Written Digits Sequence

Here's a reasonably trivial sequence which is not in the Online Encyclopedia of Integer Sequences. Start with an empty sequence then define each term as the number of characters required to write out,...
3
votes
13answers
847 views

Validate a barcode [duplicate]

A barcode of EAN-13 symbology consists of 13 digits (0-9). The last digit of this barcode is its check digit. It is calculated by the following means (the barcode ...
10
votes
7answers
695 views

Whose neighbours are hostile?

Introduction For the purposes of this challenge, we will define the neighbours of an element \$E\$ in a square matrix \$A\$ (such that \$E=A_{i,j}\$) as all the entries of \$A\$ that are immediately ...
7
votes
16answers
611 views

Extract and Divide

Challenge For a given positive integer \$n\$: Repeat the following until \$n < 10\$ (until \$n\$ contains one digit). Extract the last digit. If the extracted digit is even (including 0) multiply ...
14
votes
15answers
2k views

Missing numbers in arithmetic sum

Challenge Giving a valid arithmetic sum with some missing numbers, output the full expression. Example: ...
30
votes
18answers
2k views

Custom Number Base Converter

The powers that be want to be able to quickly convert any number they have into their own number base using any format they would like. Input Your program must accept 3 parameters. Number: The ...
18
votes
21answers
2k views

Divide the work [duplicate]

There is a job which can be decomposed into x equally-sized smaller tasks. You have a team of size y <= x, where every member ...
18
votes
34answers
972 views

Calculate power series result [duplicate]

Related: Calculate Power Series Coefficients Given a positive integer \$X\$ and a max exponent (Also a positive integer too) \$N\$ calculate the result of a power series. Example: $$X^0+X^1+X^2+\...
22
votes
2answers
472 views

Subset Sum Orderings

A set of n positive numbers has 2^n subsets. We'll call a set "nice" if none of those subsets have the same sum. ...
21
votes
2answers
670 views

Double a number's continued fraction

Your task is, given x, output 2*x. Easy right!? But there's a catch: x will be given as a (...
19
votes
38answers
2k views

Recover the power from the prime power

It seems that many people would like to have this, so it's now a sequel to this challenge! Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n ...
15
votes
36answers
2k views

Recover the prime from the prime power

Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number. Task: Given a prime power pn > 1, return the prime p. Testcases: <...
4
votes
1answer
346 views

Pair and sort from two integer lists

You are given two arbitrary integer lists, e.g. [-10, 99, -6, 43], [100, 32, 44]. You are to pick one integer from each list and ...
7
votes
4answers
904 views

Insulate the Window Glass and Foil of your house

Introduction: The best options for the glass of your house will: 1. Let through as little heat as possible in both directions (insulation-value Ug). (2. Let ...
10
votes
3answers
604 views

Interpreted arithmetic

A little known fact is that if you turn on enough language extensions (ghc) Haskell becomes a dynamically typed interpreted language! For example the following program implements addition. ...
3
votes
0answers
164 views

Make Three from One [duplicate]

Given a single digit integer and a three digit integer, output a mathematical formula that uses only the single digit and a given list of operators to equal the three digit integer. Input: A one ...
11
votes
1answer
439 views

Not just a four fours puzzle

In this variant of the Four fours puzzle your should use up to x x's (and no other number) and a defined set of operations to ...
-1
votes
1answer
223 views

Find the longest uninterrupted arc in N dimensions

See similar question for 2D case: Find the longest uninterrupted arc The challenge here is to find the longest uninterruped great circle arc around a unit hypersphere in N dimensions, with a random ...
10
votes
5answers
483 views

Find the longest uninterrupted arc

The challenge here is to find the longest uninterruped arc around a unit circle with a random amount of points distributed in random positions around it. Here is a diagram to assist my explanation: ...
20
votes
5answers
1k views

Golfing out the haters

The setup: A social network reports the number of votes a post has in two ways: the number of net upvotes (total upvotes - total downvotes), and the % of votes that were upvotes, rounded to the ...
6
votes
2answers
230 views

Minimal Triangles

Make an upside down triangle of positive integers. Every number in the triangle must be distinct. Each number is the summation of its two parents (similar to how Pascal's triangle is constructed, but ...
5
votes
27answers
2k views

Simple Factorial Challenge [duplicate]

In light of today's date... A factorial of a number n, is the product of all the numbers from 1 to n inclusive. The Challenge Given an integer n where 0 <= n <= 420, find the sum of the digits ...
16
votes
12answers
870 views

Number of surjections

Task Given 2 positive integers n and k, where n > k, output the number of surjections ...

1
2
3 4 5
11