Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [number]

This challenge is intended to be solved by using, manipulating, accepting as input, or outputting numeric values.

Filter by
Sorted by
Tagged with
16
votes
22answers
3k views

Size Does Matter (at least referring to bottles)

Introduction I have an even number of bottles, all of different sizes. Unfortunately, I only know the size of the smallest bottle: 300ml. I also know the following: Half of the bottles are twice ...
-5
votes
2answers
207 views

Fastest N times Hello World (Java/C/ C++) [closed]

Not a new one: Input N, being n, 0 ≤ n ≤ 5. Output N times "Hello World." Example: Input 3 Output Hello World. Hello World. Hello World. These 2 are my ...
9
votes
23answers
2k views

Max of the reversed of two numbers

Given two real numbers (postive or negative) in the limits of float pointing number data types, i.e., (\$-3.4e38\$ to \$3.4e38\$) not inclusive, you should output the max of the two reversed numbers. ...
13
votes
6answers
404 views

Roman Numeral Counting

Roman numerals can be (mostly) written in a one column format, because each letter intersects the top and the bottom of the line. For example: I, or 1 intersects ...
13
votes
10answers
680 views

Reach the number in minimum steps

In this challenge, you are given a number x. You have to find the minimum number of steps required to reach x from 1. At a particular point, you have two choices: 1) Increment the number by 1. 2) ...
35
votes
10answers
3k views

Interpret numbers very literally

To interpret a positive integer very literally, write it in English words (without "and"), replace hyphens with spaces, replace each resulting word with its number value, and concatenate the results ...
12
votes
8answers
440 views

Output integer given a digital clock style input

Input _ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_|| | ||_ _| | _||_| ||_| _||_| output 1234567890 Rules ...
14
votes
4answers
471 views

List where pinballs would exit a grid of bumpers from different entrance points

Inspired by this lumosity mini game, Pinball Recall We start with a rectangular grid (viewed from above) with several bumpers as follows. Entrances/exits are numbered counter-clockwise starting from ...
24
votes
14answers
3k views

Are my triangles similar?

Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ...
15
votes
10answers
1k views

Digit Date Range

NOTE: Since I'm Dutch myself, all dates are in the Dutch dd-MM-yyyy format in the challenge description and test cases. Challenge: Inputs: Start date \$s\$; End ...
4
votes
7answers
158 views

Replace by most recent nonzero [duplicate]

Given a non-empty list of decimal digits (0, 1, ..., 9), replace each zero by the most ...
42
votes
30answers
8k views

French license plates

Sandbox French License Plates French license plates come in a sequential order, following a specific pattern of numbers and letters : AB-012-CD Challenge Write ...
24
votes
18answers
3k views

Calculate the Ultraradical

What is the Ultraradical The ultraradical, or the Bring radical, of a real number \$a\$ is defined as the only real root of the quintic equation \$x^5+x+a=0\$. Here we use \$UR(\cdot)\$ to denote ...
19
votes
26answers
3k views

Convert a string of digits from words to an integer

Convert a string containing digits as words into an integer, ignoring leading zeros. Examples "four two" -> 42. ...
2
votes
9answers
232 views

Given a sequence of numbers, print out all possible sets such that the sum is less than a number

The problem has 3 inputs. L: a list of all numbers size: the size each set can be max: the max sum amongst each set The challenge is as follows: Given L, size and max, construct as many sets from ...
24
votes
20answers
7k views

1, 2, 4, 8, 16, … 33?

Challenge Write a function/program that outputs either the n'th element, or the first n elements, in the well known number ...
36
votes
50answers
7k views

I reverse the source code, you negate the input!

Blatant rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I ...
15
votes
7answers
1k views

Decimal “XOR” operator

Many programming language provide operators for manipulating the binary (base-2) digits of integers. Here is one way to generalize these operators to other bases: Let x and y be single-digit numbers ...
13
votes
11answers
761 views

Output Distinct Factor Cuboids

Output Distinct Factor Cuboids Today's task is very simple: given a positive integer, output a representative of each cuboid formable by its factors. Explanations A cuboid's volume is the product ...
14
votes
16answers
2k views

What's this constructed number's starter?

A number of programming languages construct large integers through 'concatenating' the digit to the end of the existing number. For example, Labyrinth, or Adapt. By concatenating the digit to the end, ...
24
votes
31answers
4k views

Round away from zero

Round away from zero Inspired by Round towards zero. Given a number input via any reasonable method, round the number "away from zero" - positive numbers round up, and negative numbers round down. ...
41
votes
17answers
6k views

First Number to Contain Each Letter

Given a single letter from A to Z (except J and K) as input, output the smallest non-negative integer containing that letter in its written form. Assume numbers never contain the word "and", so ...
16
votes
12answers
5k views

Divide Numbers by 0

We've all been told at some point in our lives that dividing by 0 is impossible. And for the most part, that statement is true. But what if there was a way to perform the forbidden operation? Welcome ...
14
votes
59answers
3k views

Round towards zero

This is a simple task. Given a positive or negative real number, round it to the next whole integer closer to zero. The challenge Take input through any reasonable form (stdin, function, etc.) of ...
20
votes
9answers
2k views

Levenshtein Neighbours

Most square numbers have at least 1 different square number with which their Levenshtein distance is exactly 1. For a given square \$x\$, each square that meets this condition is called a Levenshtein ...
15
votes
18answers
2k views

Simplification of numbers

How, you can’t remember the 6 or 7-digit phone number that appeared on the TV screen for a second?! Using the special technique described below, you will turn into a walking phonebook! Obviously, the ...
8
votes
6answers
939 views

Determine Beckett Grading Service (BGS) Final Grade

Introduction: Beckett Grading Service (aka BGS), is a company which encapusulates and grades Trading Card Game (TCG) cards (i.e. sport cards, Magic The Gathering, Pokémon, Yu-Gi-Oh, etc. etc.). The ...
9
votes
17answers
1k views

Alphanumeric Line and Curve Counting

Given an input string, write a program that outputs the total number of lines and curves it has. The Challenge Take input from STDIN, or any other input method. ...
-4
votes
4answers
105 views

One square root function for unsigned numbers [closed]

One square root function for unsigned numbers Write the function sqrti(x) that from one not negative integer number x, it returns the integer square root of that number truncate to the 0 digit, so ...
25
votes
54answers
6k views

Integer Lists of Noah

Introduction: I think we've all heard of it, but here a very brief summary: Noah gathered two of every species of animal on the planet, male and female, to save in his Ark during a great flood. The ...
7
votes
17answers
1k views

Tesco's Burger Relish Best Before End date number

Given a date between 2010-01-01 and 2099-12-31 as three integers (please state your order if not [year,month,day]), answer with Tesco's corresponding five-digit ...
-6
votes
4answers
192 views

Is this number a palindrome? [closed]

Input A single integer in your language's preferred format. This format is non-negotiable (no input as strings, arrays of digits, etc.), but standard I/O formats do apply if otherwise it would be ...
37
votes
31answers
14k views

Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?

Introduction: A few days ago I read this post with the same title when I came across it in the HNQ. In this question it is being discussed if the claim of president-candidate Bernie Sanders, who ...
12
votes
3answers
469 views

Implement a strongly Darboux function

According to Wikipedia, a strongly Darboux function is one for which the image of every (non-empty) open interval is the whole real line In other words, a function \$f\$ is strongly Darboux if ...
23
votes
19answers
3k views

Analog is Obtuse!

An analog clock has 2 hands*: Hour and minute. These hands circle the clock's face as time goes by. Each full rotation of the minute hand results in 1/12th of a rotation of the hour hand. 2 full ...
5
votes
0answers
180 views

Fastest way to iterate over sublattice of discrete lattice

I need to construct a functor that iterates over the linear representation of a sub-lattice of size \$d_x,d_y,d_z,d_q\$ embedded in a lattice of size \$n_x,n_y,n_z,n_q\$. The sub-lattice corner is ...
13
votes
4answers
441 views

Distributing parliament seats

Introduction In a general election, one would like to calculate a constant price per parliament seat. This means that for N >= 0 seats to be distributed and a ...
21
votes
6answers
983 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-...
12
votes
7answers
392 views

Print the total length of all “quoted” characters

Rules In this challenge, I'm going to redefine the definition of "quotes" a bit. Quotation marks (AKA quotes) are any identical characters used in pairs in various writing systems to set off direct ...
11
votes
6answers
912 views

Group Integers by Originality

Introduction: I collect twisty puzzles. Most twisty puzzles are produced and sold by Chinese companies. Most well-known companies ask permission from puzzle designers to produce their designs and ...
14
votes
31answers
2k views

Incremental Ranges!

Your task is to, given two positive integers, \$x\$ and \$n\$, return the first \$x\$ numbers in the incremental ranges sequence. The incremental range sequence first generates a range from one to \$...
20
votes
22answers
2k views

Rotated Position of Integers

Challenge: Input: A sorted list of positive integers. Output: The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times ...
8
votes
4answers
610 views

Leading and Suffering Numbers

Introduction: In Dutch, the words leading and suffering, being 'leiden' and 'lijden' respectively, are pronounced the same way. One is written with a "short ei", and one with a "long ij", as we ...
34
votes
18answers
2k views

Count rotary dial pulses in a phone number (including letters)

In your grandparents' day, dialing a phone number was done with a rotary dial like this: To dial each digit, put your finger in the corresponding hole, pull it over to the finger stop, and release it....
18
votes
22answers
2k views

To exponential digit growth and beyond!

Challenge Given a base \$1 < b < 10\$ and an index \$t \ge 1\$, output term \$x_t\$, defined as follows: \$x_1 = 11_{10}\$ \$x_{i+1}\$ is obtained by converting \$x_i\$ to base \$b\$ and then ...
-3
votes
11answers
304 views

Convert a number into “bracket” numerals

"Bracket" numerals are a type of 'numerals' I made up once, and thought would be a nice challenge here. Basically, you convert the input number into base 6, and then transliterate the ...
18
votes
15answers
2k views

Divisor Rich and Poor Numbers

Introduction In the strange world of integer numbers, divisors are like assets and they use to call "rich" the numbers having more divisors than their reversal, while they call "poor" the ones having ...
20
votes
16answers
3k views

​Cuban​ ​Primes

Given a natural number \$n\$, return the \$n\$-th cuban prime. Cuban Primes A cuban prime is a prime number of the form $$p = \frac{x^3-y^3}{x-y}$$ where \$y>0\$ and \$x = 1+y\$ or \$x = 2+y\$ ...
13
votes
12answers
404 views

Find all \$k\$-smooth pairs

Introduction In number theory, we say a number is \$k\$-smooth when its prime factors are all at most \$k\$. For example, 2940 is 7-smooth because \$2940=2^2\cdot3\cdot5\cdot7^2\$. Here, we define a ...
30
votes
19answers
5k views

Is it a Munchausen Number?

A Munchausen Number in base \$b\$, also known as a Perfect digit-to-digit invariant or PDDI is a peculiar type of positive integer where the sum of its base-\$b\$ digits raised to themselves is equal ...