Questions tagged [number]

A competition to solve a particular problem through the usage and manipulation of numbers.

Filter by
Sorted by
Tagged with
5 votes
8 answers
206 views

Funny Numbers :D

The task is to calculate the average "funniness" of a given number given the following scoring system: 1 point for each "420" in it 2 points for each "69" in it 3 points ...
Joseph's user avatar
  • 51
16 votes
10 answers
1k views

Find the longest permutations of integers from 1..k such that all neighbouring pairs sum to a square

OEIS A090461 details the ‘numbers k for which there exists a permutation of the numbers 1 to k such that the sum of adjacent numbers is a square’. This has also been the subject of Matt Parker’s ...
Nick Kennedy's user avatar
15 votes
13 answers
2k views

Keep jumping till a cycle

Objective You're on a nonempty list of integers that wraps around. You start at the leftmost entry of the list, and keep jumping to the right to the amount of the integer entry you're at. Eventually, ...
Dannyu NDos's user avatar
  • 5,143
24 votes
22 answers
3k 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\$ ...
xnor's user avatar
  • 144k
11 votes
20 answers
4k views

Add two really big numbers

Preamble We've already proven we're good at adding two numbers, but many solutions only operate on tiny numbers like 2³²-1, honestly we can do a lot better. The Challenge Given two unsigned, non-...
ATaco's user avatar
  • 10.2k
15 votes
12 answers
2k views

Half even rounding

The round function in Python 3 will round values of the form \$k+\frac{1}{2}\$ (with \$k\$ being an integer) to the nearest even integer, which is apparently better ...
bsoelch's user avatar
  • 4,741
12 votes
18 answers
1k views

Print a meter of numbers to a specified limit

Given a positive integer n, output a number meter formatted like this: ...
TKDKid1000's user avatar
15 votes
16 answers
829 views

Output the smallest increasing sequence where each term is coprime to preceding 3 terms

This sequence is defined as Starts with 1, 2, 3 The next element of the sequence is the first number greater than the previous three that is co-prime with each of the previous 3 elements in the ...
mousetail's user avatar
  • 11.4k
8 votes
8 answers
387 views

Near miss prime multiples

This challenge was originally posted on codidact. Given a number \$n \geq 3\$ as input output the smallest number \$k\$ such that the modular residues of \$k\$ by the first \$n\$ primes is exactly \$\...
Wheat Wizard's user avatar
  • 95.5k
1 vote
1 answer
153 views

Start a program so that /proc/self/cmdline contains a binary representation of the input number

I am sorry for the very long description. But i think some information of how /proc/self/cmdline works and how it can be used to get a integer input was necessary. ...
12431234123412341234123's user avatar
10 votes
13 answers
1k views

Landmine Number IV

Background You have again x3 been given the task of calculating the number of landmines in a field. But this time, we have no landmine number, and some landmines have exploded. You must calculate the ...
Jacob Creutzfeldt's user avatar
14 votes
19 answers
2k views

Vanilla Natural Logarithm Challenge

There is a challenge for multiplying two numbers so I guess this counts too Given as input a positive real number n compute its natural logarithm. Your answer ...
mousetail's user avatar
  • 11.4k
10 votes
13 answers
2k views

Landmine Number II

Background You have again been given the task of calculating the number of landmines in a field. However, we have now travelled into the flatlands. You must calculate the landmine score given a list/...
Jacob Creutzfeldt's user avatar
13 votes
26 answers
2k views

Landmine Number I

Background You have been given the task of calculating the number of landmines in a field. You must calculate the landmine score given a list/string of numbers and the landmine number. The landmine ...
Jacob Creutzfeldt's user avatar
21 votes
32 answers
2k views

Reversed Squares

Given an integer n, your task is to determine whether it is a perfect square that when reversed, is still a perfect square. You may assume n is always positive. When numbers such as 100 (10x10) are ...
Alan Bagel's user avatar
  • 3,445
6 votes
6 answers
714 views

Detect Maxima Using Persistent Homology

Inspired by this SO answer about peak detection. Background Persistent homology is a fancy term for a fancy math concept, but in this case all we care about is how it can be used for peak detection. ...
CursorCoercer's user avatar
43 votes
37 answers
3k views

Last odd digit of power of 2

Task Given \$n\$, output position of the last odd digit in the decimal representation of \$2^n\$ (counting from the end). Rules There are no odd digits for \$n=1,2,3,6,11\$ \$(2, 4, 8, 64, 2048)\$ - ...
pajonk's user avatar
  • 14.9k
15 votes
6 answers
1k views

Cube calendar numbers

Credit: Marco Verch CC BY 2.0 A two-cube calendar, as shown in the picture, uses two cubes with digits painted on the faces to display the date. For dates in the range 1-9, a leading zero is used (&...
AnttiP's user avatar
  • 7,670
22 votes
11 answers
3k views

How powerful must this e approximation be?

This challenge was inspired by this non-challenge about the natural logarithm base \$e\$ and the following pandigital approximation to \$e\$ appearing on a Math Magic page: $$\left|(1+9^{-4^{7×6}})^{3^...
Parcly Taxel's user avatar
  • 3,707
20 votes
23 answers
2k views

Borders of a Rectangular Matrix

Although it's done a few times as sub-challenge of a larger challenge, and we also have a challenge to remove the borders of a square matrix, I couldn't find a challenge to output the borders of a ...
Kevin Cruijssen's user avatar
12 votes
17 answers
2k views

Compute cumulative means efficiently

Consider a sorted array of positive floating point numbers such as: input = [0.22, 2.88, 6.35, 7.17, 9.15] For each integer \$i\$ from 1 up to the last value in ...
Simd's user avatar
  • 1,493
24 votes
5 answers
2k 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 ...
Wheat Wizard's user avatar
  • 95.5k
12 votes
15 answers
1k views

The number of solutions to Hertzsprung's Problem

Hertzprung's Problem (OEIS A002464) is the number of solutions to a variant of the Eight Queens Puzzle, where instead of placing \$n\$ queens, you place \$n\$ rook-king fairy pieces (can attack like ...
bigyihsuan's user avatar
  • 8,248
14 votes
7 answers
1k views

Gödel encoding - Part II (decoding)

Part I Previous part was considered encoding of non-empty nested lists with a positive integer. Reminding the coding procedure \$G(x)\$: If \$x\$ is a number, \$G(x) = 2^x\$ If \$x\$ is a list \$[n_0,...
lesobrod's user avatar
  • 3,231
30 votes
18 answers
3k views

Gödel encoding - Part I

Related but different. Part II Taken from the book: Marvin Minsky 1967 – Computation: Finite and Infinite Machines, chapter 14. Background As the Gödel proved, it is possible to encode with a unique ...
lesobrod's user avatar
  • 3,231
11 votes
7 answers
2k views

Zahlen auf Deutsch! (Numbers in German)

Your task is to write a program that receives a base 10 number from 0 to 99 and outputs the German name of that number with non-ASCII characters replaced with ASCII equivalents. German number names <...
Creative Name's user avatar
16 votes
7 answers
2k views

How Super is this Prime?

A super prime is a prime whose index in the list of primes is also a prime: ...
Lecdi's user avatar
  • 1,155
8 votes
3 answers
568 views

Doors and guards

Related but noticeably different You are the leader of the guard in the dungeon of an ancient castle. There are N doors in the dungeon and ...
lesobrod's user avatar
  • 3,231
13 votes
4 answers
1k views

Is it a Frog List?

Challenge: A Frog List is defined by certain rules: Each frog within a Frog List has an unique positive digit [1-9] as id (any 0...
Kevin Cruijssen's user avatar
19 votes
56 answers
5k views

Implement the `<=>` three-way comparison operator on numbers

In C++, there exists a a <=> b three-way comparison operator that, for numerical types, does the following: If a < b, ...
bigyihsuan's user avatar
  • 8,248
0 votes
6 answers
414 views

Generate number from given range

Your function must accept three numbers in any order: A signed real number (or ±Infinity) - The number (N) for which you have ...
EzioMercer's user avatar
  • 1,473
15 votes
16 answers
1k views

Imtiaz Germain Primes

Description "Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by ...
Aitzaz Imtiaz's user avatar
16 votes
7 answers
1k views

Largest Binary Area

Take the sequence of all natural numbers in binary, (1, 10, 11, ..) then write them vertically beside each-other like this (least significant bit on top; 0s have ...
mousetail's user avatar
  • 11.4k
11 votes
14 answers
944 views

Multibase Numbers

(Similar: Through the bases) Normally, our number system is base ten, with the digits 0123456789. However, we can increase or decrease the base count (so ...
Infigon's user avatar
  • 505
18 votes
24 answers
2k views

Shortest code to generate all Pythagorean triples up to a given limit

Generate the shortest possible code in any programming language that can generate all Pythagorean triples with all values not exceeding a given integer limit. A Pythagorean triple is a set of three ...
Aitzaz Imtiaz's user avatar
10 votes
5 answers
382 views

Consolidate a 6-axis 2-dimensional Vector

Typically, when we want to represent a magnitude and direction in 2D space, we use a 2-axis vector. These axes are typically called X and Y: This isn't always convenient, however. The game BattleTech ...
Pavel's user avatar
  • 9,351
12 votes
71 answers
3k views

Summing the Digits of a Number

Challenge Given a non-negative integer, find the sum of its digits. Rules Your program must take a non-negative integer as input. Your program should output the sum of the digits of the input ...
Aitzaz Imtiaz's user avatar
11 votes
5 answers
603 views

Whole Number Groups

Given a list of fractions, group them so that each group sums to a whole number. This should be done in such a way to maximize the number of non-empty groups. You may assume a solution exists. Order ...
mousetail's user avatar
  • 11.4k
12 votes
6 answers
608 views

Number Clusters

Your task is to create a program or function, that when given an input list of nonnegative integers of length \$l \ge 2\$ and a nonnegative integer \$c\$ where \$2 \le c \le l\$, group the list into \$...
Yousername's user avatar
  • 3,430
13 votes
16 answers
1k views

Find opposite string

Your function must accept one string and return the opposite The opposite string is a string where all characters go in reverse order, all letters are replaced with the opposite mirror letter from the ...
EzioMercer's user avatar
  • 1,473
17 votes
19 answers
3k views

Print all pandigital numbers

Given a base as input, output all pan-digital numbers. A number is pan-digital if it includes every digit in that base at least once, possibly multiple times. Every number is considered to contain an ...
mousetail's user avatar
  • 11.4k
9 votes
15 answers
2k views

Sum of numbers of arbitrary length

Your function must accept 2 strings which are correct numbers. It needs to sum them up (without rounding and floating point errors) and return the result (which is also a correct number) without any ...
EzioMercer's user avatar
  • 1,473
22 votes
27 answers
3k views

Sum of Consecutive Squares

Your task Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers. Test cases Truthy: ...
The Thonnu's user avatar
  • 17.5k
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 ...
Stewie Griffin's user avatar
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 ...
Ron Sijm's user avatar
  • 361
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 ...
Kevin Cruijssen's user avatar
17 votes
16 answers
728 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: ...
mousetail's user avatar
  • 11.4k
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), ...
Ginger's user avatar
  • 5,390
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 ...
l4m2's user avatar
  • 19.1k
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 ...
Wheat Wizard's user avatar
  • 95.5k

1
2 3 4 5
26