Questions tagged [arithmetic]
Challenges related to elementary arithmetic.
547 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
3
votes
4
answers
242
views
Fill in the blanks of this equation
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 ...
12
votes
22
answers
1k
views
Find all unique quintuplets in an array that sum to a given target
Inspiration: Leetcode's [3Sum] link
Problem
Given an array nums of n (not necessarily distinct) integers, and given a target ...
8
votes
7
answers
838
views
Complex Exponentiation [closed]
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 ...
18
votes
22
answers
1k
views
Infer pluses and minuses
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, ...
-3
votes
8
answers
1k
views
Number of cigarettes that can be made from a given number of butts
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 ...
11
votes
12
answers
2k
views
Solve a squared cryptarithm
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 ...
20
votes
14
answers
2k
views
Number of ways to partition n into n = K + ꓘ
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 ...
26
votes
14
answers
4k
views
80% of respondents agreed...
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 ...
13
votes
21
answers
4k
views
German pharmacy payment
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 ...
24
votes
23
answers
4k
views
American odds to probabilities
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\$ ...
9
votes
11
answers
896
views
Otteretto Classic game scoring method
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. ...
44
votes
18
answers
3k
views
Compare Two Fractions With ASCII Art
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 ...
22
votes
26
answers
4k
views
Given 4 fence lengths, what's the largest rectangular yard you can make?
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 ...
24
votes
5
answers
3k
views
Add two real numbers ... probably
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 ...
15
votes
80
answers
4k
views
Summing the Digits of a Number
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 ...