Questions tagged [number]
A competition to solve a particular problem through the usage and manipulation of numbers.
1,300
questions
13
votes
16
answers
3k
views
Create a bingo card generator
Bingo
Bingo is a numbers game where players match randomly drawn numbers to the numbers on their cards. Each bingo card is a square grid with 25 spaces, and the columns of the grid are labeled with ...
23
votes
34
answers
2k
views
Shortest digid-app GetPercentageRounds function
Context
So the Dutch "Ministerie van Binnenlandse Zaken en Koninkrijksrelaties" (NL) - "Ministry of the Interior and Kingdom Relations" (EN) recently released the source code of ...
13
votes
8
answers
1k
views
Toggle some bits and get an actual square
Inspired by the title of the Toggle some bits and get a square challenge.
In that challenge you output how many bits should be toggled, in order for the base-10 representation of the binary to become ...
17
votes
16
answers
731
views
Form a subset that is a continuous range
Given a list of lists of positive integers, output a subset of them so their union forms a continuous non-empty range with no numbers missing. For example, consider this input:
...
15
votes
23
answers
2k
views
Find the first run of numbers summing to n
Given as input a positive nonzero integer n >= 10 and a sequence of digits 0-9 (which may be taken as a string or a list), ...
16
votes
15
answers
1k
views
Division between two strings
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 ...
13
votes
10
answers
2k
views
Round to nicer numbers
The standard way to round numbers is to choose the nearest whole value, if the initial value is exactly halfway between two values, i.e. there is a tie, then you choose the larger one.
However where I ...
13
votes
8
answers
1k
views
Calculate my income tax
Background
Here in the UK1, these are the income tax rules:
You get a personal allowance (untaxed) of up to £12,570:
If you earn less than £100,000, you get the full £12,570 as personal allowance
...
13
votes
35
answers
736
views
Create \$n\$ sublists with the powers of two (1, 2, 4, 8, 16...)
Challenge:
Given the input number n. It should give me nested sublists of n layers with the power of two numbers for each level. ...
34
votes
57
answers
5k
views
Sum every second digit in a number
I have a number like this:
n = 548915381
The output should be the sum of every second digit of that number. In this case 26:
...
12
votes
30
answers
2k
views
Find the nth number where the digit sum equals the number of factors
(This is OEIS A057531.)
Your task
Given a positive integer, \$n\$, find the \$n\$th number where the digit sum equals the number of factors
Explanation
For example, let's take 22:
Its factors are \$[1,...
15
votes
14
answers
1k
views
1 to N column and row sums
Inspiration
There is a problem on the most recent AMC 12B test, the one held on November 16, 2022, which goes like this:
(AMC 12B 2022, Question 17)
How many \$4\times4\$ arrays whose entries are \$0\...
17
votes
17
answers
2k
views
Number to letters
Your task
Given a numerical string or integer \$\ge 0\$ (which may have leading zeros), convert it to letters using the below rules.
Rules
Loop through the digits:
If the digit is ...
5
votes
21
answers
506
views
Iterate through addition of number sequence until a single digit [closed]
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'...
27
votes
12
answers
1k
views
Increment, decrement, undo, peek
Write a program or function (hereafter "function") that returns or prints the source code of four new functions: Increment, decrement, undo, and peek.
The initial function contains an ...
11
votes
6
answers
435
views
Conversions Galore!
Imagine that there are \$n\$ different types of objects \$O_1,O_2,O_3,\ldots,O_n\$ and they each have a conversion factor \$k_1,k_2,k_3,\ldots,k_n\$. You can, for any \$1\le i\le n\$, convert \$k_i\$ ...
7
votes
5
answers
861
views
Fastest Gematria calculator
Gematria is an ancient Jewish method to determine a numeric value of a letter sequence, using a fixed value for each letter. Gematria is originally applied to Hebrew letters, but for the context of ...
17
votes
11
answers
2k
views
Numbers vs. Strings: Language fitness challenge
inspired by thejonymyster's idea
Rules
This challenge is about finding languages that are very suitable for one task but quite the opposite in the other. The two tasks share a theme, but Task 1 is ...
13
votes
15
answers
2k
views
Advanced Binary Number System
Your task is to write a program that calculates the amount of different ways to display any given whole positive number using the following rules:
Meet the 'advanced binary system':
Any whole positive ...
6
votes
14
answers
1k
views
Number of ways to make an amount with coins
This is not a duplicate of Sum of combinations with repetition. This question considers 1+2 to be the same as 2+1. The other ...
12
votes
2
answers
754
views
Solving an easy Sudoku in increasing digit order
Introduction:
I'm old-fashioned and still read a physical newspaper in the morning while eating my breakfast. Although I don't like Sudoku that much, I do solve the Light-complexity ones, which are ...
19
votes
25
answers
2k
views
Carry-less sum given a base b
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 ...
4
votes
5
answers
277
views
Rotatable numbers (Upside down) [duplicate]
Searching for rotatable numbers, like: 68089
If you consider numbers upside-down,
6 looks like ...
15
votes
20
answers
1k
views
Cartesian - polar conversion couple
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 ...
2
votes
0
answers
353
views
Decompose number N into the sum of three triangular numbers [closed]
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 ...
7
votes
5
answers
333
views
Generate number set with conditions using n numbers
Generate \$T=\{T_1,...,T_x\}\$, the minimum number of \$k\$-length subsets of \$\{1,...,n\}\$ such that every \$v\$-length subset of \$\{1,...,n\}\$ is a subset of some set in \$T\$
Here, \$n > k &...
22
votes
45
answers
2k
views
Shifted auto-sum
Let’s take a positive integer such as 123. We define the shifted auto-sum of this integer as follows:
123 has 3 digits. We thus consider 3 copies of 123.
We stack ...
19
votes
21
answers
2k
views
Multiply numbers by their depth
Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested.
For example, with the list ...
24
votes
12
answers
3k
views
Golf GitHub's Pager Logic
Background
When searches return many pages of results, GitHub avoids cluttering their UI by eliding page links. Instead, their UI lets you select:
Pages at the beginning of the results.
Pages near ...
15
votes
16
answers
1k
views
Implement Binary Exponentiation
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-...
16
votes
14
answers
969
views
Number of binary partitions
We all know that any positive integer can be represented as the sum of powers of two. This is how binary representations work. However there's not just one way to do this. The canonical method, ...
14
votes
16
answers
2k
views
Bloons TD 6 Upgrade Paths
Background
The monkeys need help organizing their defense and have asked you, Benjamin the code monkey, to create a program that will list all tower upgrade options. Each tower has three unique ...
22
votes
22
answers
2k
views
Decipher a squashed sequence
Given a string containing a sequence of ascending consecutive positive integers, but with no separators (such as 7891011), output a list of the separated integers. ...
13
votes
4
answers
472
views
Not-Roman-Numeral Addition
Write the shortest program or function that mimics the addition in this XKCD strip:
Input
Two positive decimal integers containing only the digits 150.
Output
The ...
32
votes
27
answers
6k
views
Doing a little trolling with the microwave timer
Related
Sometimes when I use my microwave, I do a little trolling and enter times such as 2:90 instead of 3:30 because they end ...
24
votes
25
answers
3k
views
How far from binary?
Given a decimal integer n as input, output the smallest (in terms of absolute value) decimal integer m such that the absolute ...
12
votes
17
answers
1k
views
Extract the contained powers of two!
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
...
37
votes
50
answers
5k
views
Previous Fibonacci number
The sequence of Fibonacci numbers is defined as follows:
\$
F_0 = 0 \\
F_1 = 1 \\
F_n = F_{n-1} + F_{n-2}
\$
Given a Fibonacci number, return the previous Fibonacci number in the sequence. You do not ...
15
votes
28
answers
2k
views
There's more than one way to skin a set
Given a set of positive integers \$ S \$, output the set of all positive integers \$ n \$ such that \$ n \$ can be made by summing a subset of \$ S \$ in more than one different way, i.e., that are ...
5
votes
19
answers
2k
views
Palindromic Powers
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 ...
21
votes
8
answers
3k
views
ASCII-Art n'th Root
Challenge:
Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal ...
14
votes
6
answers
692
views
Rounding a range
You have a line with two endpoints a and b (0 ≤ a < b) on a 1D space. When ...
22
votes
9
answers
991
views
Sequence of integers not the sum of powers of earlier terms
Starting with 1, output the sequence of integers which cannot be represented as the sum of powers of earlier terms. Each previous term can be used at most once, and the exponents must be non-negative ...
14
votes
19
answers
1k
views
Words with Easy Letters in a Word Search
Introduction:
Apparently I keep coming up with word search related challenges lately. :)
When I do the word search in the Dutch news paper, some words are very easy to find because they contain ...
16
votes
15
answers
1k
views
Average-ignorant sets of integers
Recently a friend of mine posed the following:
What subset of the integers satisfies the condition if distinct a and b are in the subset, their average is not in the subset? I know the set of non-0 ...
9
votes
38
answers
3k
views
Find the weight of five apples
Problem
John bought 5 apples. You are given the weights of every group of four apples, and must then find the weights of the apples themselves.
For example, if all apples without the first one weigh ...
17
votes
17
answers
3k
views
Numbers in 2050
It's 2050, and people have decided to write numbers in a new way. They want less to memorize, and number to be able to be written quicker.
For every place value(ones, tens, hundreds, etc.) the number ...
5
votes
6
answers
545
views
Batt to the Basics
One of your acquaintances has a hobby of making make-shift electrical gadgets using various types of batteries. However, since they're thrifty, they want to use as few batteries as possible for their ...
13
votes
17
answers
1k
views
The interstice of two binary numbers
Given two integers, compute the two numbers that come from the blending the bits of the binary numbers of equal length(same number of digits, a number with less digits has zeros added), one after the ...
10
votes
8
answers
2k
views
How many times do I break my own rule?
Introduction:
In my recent Strikethrough the Word Search List challenge I mentioned the following:
When I do the word-search puzzles, I (almost) always go over the words in order, and strike them ...