Questions tagged [integer]

For challenges involving the manipulation of integers.

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

The Binary Binary Expansion

Normally, we decompose a number into binary digits by assigning it with powers of 2, with a coefficient of 0 or 1 for each term: ...
8
votes
14answers
530 views

Count the Palindromes [duplicate]

Given a number n, calculate the amount of bases in the range of [2, n) in which b(n) is a ...
7
votes
1answer
341 views

Playing Darts: become an amateur with the most efficient prioritizing

Introduction: I think most people will know how darts work. But since some might not, here are the rules of playing Darts in a nutshell: Amount of players: 2 Starting points: 501 Goal: Get your ...
24
votes
20answers
2k views

Circularly moving sum

Inspired by a question at Stack Overflow. Given a non-empty array of integers x and a positive integer n, compute the sum of ...
12
votes
13answers
2k views

Skip like a frog!

Given an array of non-negative integers, your task is to only keep certain elements of it, as described below. Let's say the array is ...
20
votes
25answers
1k views

Keep/Drop/Increase Sequence

Here is the sequence I'm talking about: {1, 4, 5, 9, 10, 11, 16, 17, 18, 19, 25, 26, 27...} Starting from 1, keep 1, drop the next 2, keep the next 2, drop 3, ...
0
votes
0answers
70 views

Turn an integer n into an N-DIMENSIONAL list [duplicate]

Inspired by this question. Given an integer n, create an n-dimensional list of "length" n in every dimension, where every element is n. Rules: If your language has a built-in that does this, you ...
15
votes
97answers
6k views

Turn an integer n into a list containing it n times

Given an integer n as input, return a list containing n, repeated n times. For example, the ...
34
votes
35answers
2k views

Undo a Range of Numbers

It is fairly simple to, given a number n, create a range from 0 to n-1. In fact, many ...
18
votes
16answers
2k views

It's a Bit of a Stretch․․․

Input: We take two inputs: An input b with two distinct values: Left and Right.† And a ...
2
votes
1answer
241 views

Syllables in a Number [closed]

Make a program/function which takes in an integer from 0 to 999999999999 (inclusive) as input and returns how many syllables it has when spoken in English. Make your code short. Specification A ...
20
votes
21answers
3k views

Fold the integer to save space!

The crazy mathematician owns a wide collection of numbers, and therefore the space he has left is quite limited. To save some, he must fold his integers, but unfortunately he is really lazy. Your task,...
31
votes
34answers
4k views

Make a Spiky Box

Given two positive integers, W and H, output an ASCII-art box whose border is made of slashes (/ and \) with W "spikes" on the ...
14
votes
12answers
747 views

prepend,append-Sequence

Task The prepend,append-Sequence is defined recursively, like this a(1) = 1 a(n) = a(n-1).n , if n is even a(n) = n.a(n-1) , if n is odd where the . represents an integer concatenation. So the ...
22
votes
8answers
1k views

Products that equal a sum and vice versa

A fun pair of equivalences is 1 + 5 = 2 · 3 and 1 · 5 = 2 + 3. There are many like these, another one is 1 + 1 + 8 = 1 · 2 · 5 and 1 · 1 · 8 = 1 + 2 + 5. In ...
29
votes
20answers
2k views

Float 754 to Hamming

You will be given as input an integer k in the range from -4503599627370496 (−252) to ...
22
votes
13answers
1k views

Collapse consecutive integers

Related: Tell me how many math problems I have to do! Challenge Given a strictly positive strictly ascending integer list L and an integer 3 ≤ N ≤ length of L, replace the middle integers of L's ...
19
votes
6answers
519 views

The bouncing sequence

Let us define a sequence. We will say that \$a(n)\$ is the smallest number, \$x\$, that has the following properties: \$x\$ and \$n\$ are co-prime (they share no factor) \$x\$ does not appear ...
23
votes
5answers
869 views

Complex Dice Rolling Expressions

Background I play D&D on a regular basis with some friends. While talking about the complexity of some systems/versions when it comes to rolling dice and applying bonuses and penalties, we ...
16
votes
20answers
1k views

Find the Serialized Integer

Task Write a program that will take (as input) a positive integer. It will then count up from 0, appending each integer to a ...
18
votes
24answers
2k views

Find the nearest biquadratic number

A biquadratic number is a number that is the fourth power of another integer, for example: 3^4 = 3*3*3*3 = 81 Given an integer as input, output the closest ...
12
votes
6answers
337 views

Find the coefficients of a rational generating function

If we write a sequence of numbers as the coefficients of a power series, then that power series is called the (ordinary) generating function (or G.f.) of that sequence. That is, if for some function <...
20
votes
14answers
2k views

Pascal's Rhombus

Pascal's Rhombus (which is actually a triangle) is obtained by adding in the pattern: * *** x instead of * * x This ...
15
votes
10answers
2k views

Fewest operations to 100

Overview Given a list of digits, find the fewest operations to make 100 Input A string of digits, which may or may not be in numerical order. The order of the digits cannot be changed, however plus ...
12
votes
10answers
1k views

The Lehmer-Comtet sequence

The Lehmer-Comtet sequence is a sequence such that a(n) is the nth derivative of f(x) = xx with respect to x as evaluated at x = 1. Task Take a non-negative integer as input and output the nth term ...
25
votes
33answers
2k views

Triangular Dependencies

A triangular number is a number that is the sum of n natural numbers from 1 to n. For example ...
33
votes
61answers
5k views

Find the highest unique digit

Surprisingly we haven't had a simple "find the highest digit" challenge yet, but I think that's a little too trivial. Given input of a non-negative integer, return the highest unique (ie not repeated)...
30
votes
18answers
2k views

N-dimensional identity “matrix”

Given a positive integer n, output the N-dimensional identity "matrix", which is the N^N ...
16
votes
7answers
1k views

Spin the Calculator

Introduction: Let's take a look at a standard Calculator in Windows: For this challenge, we'll only look at the following buttons, and ignore everything else: ...
58
votes
18answers
6k views

Count like Chuck Norris

As is well known, Chuck Norris counted to infinity. Twice Besides, Chuck Norris can count to infinity backwards. Also, although perhaps less known, Chuck Norris can speak a little Spanish in ...
5
votes
16answers
916 views

Emoticon numbers!

(related) Your challenge is to output the highest number you can. You can output as a number or as a string. You must output something that matches the regex ^\d+$,...
16
votes
12answers
774 views

Counting N-bit integer multiplication overflows

Given a positive integer N, output the number of pairs of integers 0 <= a <= b < 2**N such that ...
22
votes
19answers
4k views

CSI: Minecraft Items

Minecraft 1.12 will be released tomorrow, so let's celebrate! Write code that takes in a non-negative integer N which represents the number of items of something in Minecraft. Output it in a way more ...
11
votes
7answers
682 views

Do two numbers contain unique factorials?

Break two numbers up into their factorials; if they share any, return a falsey value. Otherwise, return a truthy value. (inspired by this recent question) In other words, write each input number as ...
7
votes
28answers
2k views

Do two numbers contain unique powers of 2

Break two numbers up into their powers of 2, if they share any, return a falsey value. Otherwise, return a truthy value. If one input is 0, the answer will always ...
16
votes
3answers
590 views

Miller-Rabin Strong Pseudoprimes

Given a non-negative integer N, output the smallest odd positive integer that is a strong pseudoprime to all of the first N ...
34
votes
65answers
3k views

Interleave numbers from 1 to n, with the same numbers reversed

A simple one: Take a positive integer n less than 1000, and output the integers from 1 to n interleaved with the integers from n to 1. You must concatenate the numbers so that they appear without any ...
6
votes
7answers
360 views

Find all Number Relations

Inspired by: Find an Unrelated Number Challenge Given two positive integers as input, output the mathematical operations that can be used on those inputs to generate every number from ...
20
votes
18answers
2k views

Find an Unrelated Number

Given 2 non-negative integers as input, output a non-negative integer that cannot be created through any mathematical operators on the 2 inputs. For example, given inputs ...
2
votes
15answers
603 views

Infinite Sequence of Unique Random Integers

Output an infinite sequence of positive integers, such that, for each element in the sequence, all positive integers that have not yet been output have a positive probability of being chosen, and no ...
8
votes
34answers
1k views

How long is my number: Restricted Version

Find the original challenge here Challenge Given an integer, Z in the range -2^31 < Z < 2^31, output the number of ...
26
votes
56answers
5k views

How long is my number?

Challenge Given an integer, Q in the range -(2^100) ≤ Q ≤ 2^100, output the number of digits in that number (in base 10). ...
46
votes
27answers
2k views

Divisor skyline

For any positive integer k, let d(k) denote the number of divisors of k. For example, ...
9
votes
15answers
733 views

Implement Euler's method

The goal of this challenge is to use Euler's method to approximate the solution of a differential equation of the form f(n)(x) = c.† The input will be a list of integers in which the nth value ...
65
votes
5answers
5k views

Powerprogramming: O(1^N), O(N^1), O(2^N), O(N^2) all in one

Write a program (or function) that exhibits four common big O time complexities depending on how it is run. In any form it takes in a positive integer N which you may assume is less than 231. When ...
30
votes
21answers
2k views

Find the nearest greater number

The task Given any array of integers, e.g.: [-1,476,578,27,0,1,-1,1,2] and an index of that array (this example uses 0 based indexing, though you can use 1 ...
41
votes
119answers
9k views

Stay away from zero

Task Given a non-negative integer n, output 1 if n is 0,...
15
votes
8answers
1k views

Decompose a number into triangles

Given an integer n, decompose it into a sum of maximal triangular numbers (where Tm represents the mth triangular number, or the sum of the integers from 1 to m) as follows: while n > 0, find the ...
40
votes
31answers
2k views

Moving modest minimum

Inspired by a question over at Stack Overflow. The title here is entirely my fault. The challenge Given a list of positive integers containing at least two entries, replace each number by the ...
16
votes
5answers
537 views

Do a BackFlip for ais523!

This challenge is a prize for ais523 for winning the "Rookie of the Year" category in "Best of PPCG 2016". Congratulations! BackFlip is an esoteric programming language made by user ais523, who has ...