Skip to main content

Questions tagged [arithmetic]

Challenges related to elementary arithmetic.

Filter by
Sorted by
Tagged with
14 votes
17 answers
1k views

Each quarterback in the NFL is given a passer rating at the end of the game, which measures how good their forward passes were. It is not strictly a basic arithmetic formula, and is calculated as ...
Parcly Taxel's user avatar
  • 4,749
3 votes
4 answers
253 views

Your task is to write a program or function that can fill in the blanks of an equation provided in this form: _ + _ / _ = 4 In this case, a valid solution would be: 2 + 8 / 4 = 4 Each blank must be ...
Steve Bennett's user avatar
12 votes
22 answers
1k views

Inspiration: Leetcode's [3Sum] link Problem Given an array nums of n (not necessarily distinct) integers, and given a target ...
CrSb0001's user avatar
  • 867
8 votes
7 answers
850 views

As the title says! Raise one complex number to the power of another. (a+bi)^(c+di)(using the principal branch of the complex logarithm) Requires four inputs a, b, c, d. You can combine a, b, c, d into ...
ThePlaneGuy45's user avatar
20 votes
24 answers
2k views

The problem Consider an equation such as      "3 ± 2 ± 4 ± 1 = 4"      and determine if there exists a sequence of pluses and minuses that makes it arithmetically correct. If it exists, ...
Nicola Sap's user avatar
  • 3,823
-3 votes
8 answers
1k views

Assumption A cigarette can be made by combining four cigarette butts. Cigarette butts last infinitely until smoked. Explanation Say you have 31 butts. That means, you can make 7 cigarettes from 28 ...
Siddharth Singh's user avatar
11 votes
12 answers
2k views

Inspired by Greg Martin's "Shiny cryptarithm" puzzle. A cryptarithm is a game consisting of a mathematical equation among unknown numbers, whose digits are represented by letters of the ...
enzo's user avatar
  • 2,153
20 votes
14 answers
2k views

In this challenge you are asked to find in how many ways we can express a positive integer n as the sum of two positive integers ...
ZaMoC's user avatar
  • 25.5k
26 votes
14 answers
4k views

Sometimes I see a claim like "80% of respondents agreed" and I think "what was your sample size? 5?" because, of course, with a sample size of 5 it's possible to get 80% to agree ...
msh210's user avatar
  • 3,511
13 votes
21 answers
4k views

Your task is to calculate the amount you have to pay for prescribed medication at a pharmacy in Germany. The amount is simply based on the full price of the item, which will be your input. It is a ...
corvus_192's user avatar
  • 5,952
24 votes
23 answers
4k views

American odds (aka moneyline odds) are numbers like \$+150\$ or \$-400\$ used to express how much a winning bet would pay out. Convert odds to a fair win probability like this: Positive odds \$+n\$ ...
xnor's user avatar
  • 150k
9 votes
11 answers
913 views

Brief description of the game In the game Otteretto Classic (which you can test directly in your browser; try it!) the player has to form palindromic sequences using adjacent cells on a square grid. ...
Luis Mendo's user avatar
  • 107k
44 votes
18 answers
3k views

Challenge Write a program or function that takes in 4 non-negative integers, A, B, C, and D, that represent two fractions, A/B and C/D, where B and D are non-zero and A <= B and C <= D. Output ...
blaketyro's user avatar
  • 809
22 votes
26 answers
4k views

Here's a very simple little problem that I don't believe has been asked before. Challenge Write a program or a function that takes in four positive integers that represents the lengths of movable but ...
blaketyro's user avatar
  • 809
24 votes
5 answers
3k views

The problem statement here is pretty simple, take two real numbers on the range [0,1) as input and output their sum, with probability 1. The catch here is that there are a lot of real numbers. There ...
Wheat Wizard's user avatar
  • 103k
15 votes
81 answers
4k views

Challenge Given a non-negative integer, find the sum of its decimal digits. Rules Your program must take a non‐negative integer as input. Your program should output the sum of the digits of the ...
aitzazisstuffed's user avatar
12 votes
9 answers
2k views

Introduction An abstract syntax tree (AST) is a tree of tokens that shows their connection to each other and syntactical meaning. They are commonly used in compilers and static analysis tools, as ...
Michael M.'s user avatar
16 votes
15 answers
2k views

Inverse function of this challenge To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick ...
l4m2's user avatar
  • 32.6k
5 votes
21 answers
619 views

Challenge: With any given number that has multiple digits, every digit in the number needs to repeatedly be summed together until the sum is a single digit number. To make things interesting, if there'...
Larsenv's user avatar
  • 87
19 votes
25 answers
2k views

Given a list of positive integers \$\mathcal I=I_1,I_2,I_3,...,I_n\$ and a base \$b>1\$ return their "carry-less sum", i.e. represent \$\mathcal I\$ in base \$b\$ and sum digit-by-digit ...
loopy walt's user avatar
  • 16.9k
18 votes
22 answers
1k views

We don't have a challenge for conversion between Cartesian and polar coordinates, so ... The challenge Write two programs (or functions) in the same language: one that converts from polar to ...
Luis Mendo's user avatar
  • 107k
19 votes
9 answers
1k views

Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592. If now each digits is ...
Domenico's user avatar
  • 2,463
2 votes
0 answers
439 views

It is known that any natural number can be decomposed into the sum of three triangular numbers (assuming 0 is triangular), according to Fermat's Polygonal Number Theorem. Your task is to come up with ...
Study's user avatar
  • 45
17 votes
17 answers
2k views

Background In programming, there is a recursive algorithm called binary exponentiation, which allows for large integer powers to be calculated in a faster way. Given a non-zero base \$x\$ and a non-...
Aiden Chow's user avatar
  • 14.6k
12 votes
17 answers
1k views

Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases ...
Qaziquza's user avatar
  • 1,693
5 votes
19 answers
2k views

Powers We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$. Palindrome We define an ...
Sunny's user avatar
  • 2,004
17 votes
12 answers
3k views

A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius <...
Jitse's user avatar
  • 8,124
9 votes
2 answers
385 views

This expression actually has an omitted pair of parentheses. 1 + 2 * 3 To make things clear, it should be, 1 + (2 * 3) Even ...
xiver77's user avatar
  • 2,395
15 votes
7 answers
3k views

Let \$S \subset \mathbb N_{\geq0}\$ be a subset of the nonnegative integers, and let $$ S^{(k)} = \underbrace{S + S + \dots + S}_{k\ \textrm{times}} = \{ a_1 + a_2 + \dots + a_k : a_i \in S\}. $$ For ...
Peter Kagey's user avatar
  • 8,175
12 votes
6 answers
795 views

Inspired by How to write down numbers having an infinity of decimals? Link 🇫🇷 Background From Wikipedia: for almost all real numbers \$x\$, coefficients \$a_i\$ ...
Julian's user avatar
  • 3,386
26 votes
27 answers
3k views

Story My local pizza delivery introduced new discount. You get 50% discount from every second item on your order. But being greedy capitalists, they forgot to mention that they will rearrange items ...
talex's user avatar
  • 927
28 votes
12 answers
2k views

Consider a binary tree built the following way: The root node is \$1\$ For a given node \$n\$: If \$n\$ is odd, its only child is \$2n\$ If \$n\$ is even, one of its children is \$2n\$. If \$\frac {...
caird coinheringaahing's user avatar
19 votes
4 answers
812 views

Let \$A\$ be a square matrix that is at least \$2 \times 2\$ where each element is an integer. \$A^2 = A \times A\$ will then have the same dimensions as \$A\$, and will have integer elements. For ...
caird coinheringaahing's user avatar
15 votes
41 answers
2k views

The challenge is simple: Read 3 letters from a system input¹ and convert them to numbers (A-1, B-2, C-3...Z-26)². Print each of those numbers in the order the ...
Rowan McAlpin's user avatar
6 votes
6 answers
445 views

To celebrate the island's next Founder's Day, colored filters (fuchsia, chartreuse, and aquamarine*) have been installed in every lighthouse. All lighthouses begin operation with their fuchsia filter,...
DjinTonic's user avatar
  • 636
25 votes
11 answers
2k views

Lighthouses on an island have blink codes that let ships know which lighthouse they are seeing. Input should be strings of S and L. Here is a (Python) example of codes for 4 lighthouses as a list of ...
DjinTonic's user avatar
  • 636
39 votes
15 answers
3k views

Consider a square grid on the plane, with unit spacing. A line segment of integer length \$L\$ is dropped at an arbitrary position with arbitrary orientation. The segment is said to "touch" ...
Luis Mendo's user avatar
  • 107k
19 votes
10 answers
1k views

Let \$R, C\$ be positive integers and let \$0 < s \leq 1\$. Consider the \$R \times C\$ matrix \$\mathbf M\$ defined as \begin{equation} M(i,j) = \frac{\mathrm{mod}\,(j, i^s)}{R^s}, \quad i = 1, \...
Luis Mendo's user avatar
  • 107k
8 votes
3 answers
914 views

The Lost Numbers are 4, 8, 15, 16, 23, 42. Your goal is to create an expression to output them all. Your allowed characters are 0123456789, ^+-*/, (), % for modulo and n as the single variable allowed....
AndrewTheCodegolfer's user avatar
7 votes
3 answers
241 views

Challenge: Given an expressions made of additions and multiplications, output an expression that is a sum of products. The output must be equivalent to the input modulo the law of distribution. For ...
Trebor's user avatar
  • 805
5 votes
10 answers
1k views

I have to fill in 2fa codes all day. They're 6-digit strings. One day I noticed that not once did any of these codes contain 6 unique digits, like 198532 There was always at least one double, like ...
ToonAlfrink's user avatar
  • 1,324
28 votes
13 answers
3k views

The Collatz sequence Given a positive integer \$a_1\$, the Collatz sequence with starting value \$a_1\$ is defined as \begin{equation} a_{n+1} = \begin{cases} a_n/2 & \mathrm{if}\ a_n\ \mathrm{is}\...
Luis Mendo's user avatar
  • 107k
22 votes
14 answers
3k views

Introduction How to prove that 1 = 2: 1 = 2 2 = 4 (*2) -1 = 1 (-3) 1 = 1 (^2) You can just multiply both sides by 0, but that's cheating. This is just bending the ...
emanresu A's user avatar
  • 46.2k
20 votes
6 answers
2k views

You are given 3 non negative numbers: \$x\$, \$y\$ and \$z\$, and must minimize the number of digits (non negative) inserted at any place in the numbers \$x\$, \$y\$, or \$z\$ to make $$x + y = z$$ (a ...
cheems's user avatar
  • 619
11 votes
21 answers
3k views

Introduction When playing Mario Kart the other day, an interesting question popped up when a Grand Prix with my 2 roommates, 9 AI drivers and myself seemed to be fairly close and therefore exciting ...
Der_Reparator's user avatar
14 votes
16 answers
846 views

Inspired by this challenge, and similar to this and this. After seeing these, I figured I would continue the trend as there was no inclusive/exclusive sum. The goal here is to sum an interval of ...
Underslash's user avatar
  • 1,739
1 vote
11 answers
415 views

Given a list of integers, such as {1, 4, 2, 8, 10}, TI-Basic's ΔList will determine the difference between every overlapping ...
rydwolf's user avatar
  • 19.3k
17 votes
17 answers
3k views

Relatable scenario: I'm going to the store to buy a single item, but only have a $100k bill. As a result, I need exactly $99,979 in change, and in the fewest coins/bills possible because I'm quite ...
rydwolf's user avatar
  • 19.3k
16 votes
19 answers
2k views

We had a challenge on Multiplicative Persistence here. As a recap, to get a multiplicative persistence of a number, do these steps: Multiply all the digits of a number (in base \$10\$) Repeat Step 1 ...
math scat's user avatar
  • 9,538
15 votes
14 answers
2k views

Left in sandbox for at least 3 days. I want to verify if this inequality is true: for \$n\geq4\$, if \$a_1,a_2,a_3,\dots,a_n\in R_+\cup\{0\}\$ and \$\sum_{i=1}^na_i=1\$, then \$a_1a_2+a_2a_3+a_3a_4+\...
atzlt's user avatar
  • 507

1
2 3 4 5
11