Questions tagged [integer]

For challenges involving the manipulation of integers.

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
514 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
858 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
332 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: ...
57
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
911 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
773 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
680 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
562 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
597 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). ...
44
votes
26answers
2k views

Divisor skyline

For any positive integer k, let d(k) denote the number of divisors of k. For example, ...
9
votes
15answers
726 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 ...
66
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 ...
40
votes
118answers
8k 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
527 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 ...
26
votes
11answers
5k views

Is this number an exact power of -2: (Very) Hard Mode

This is a version of the recent challenge Is this number an integer power of -2? with a different set of criteria designed to highlight the interesting nature of the problem and make the challenge ...
41
votes
40answers
7k views

Is this number an integer power of -2?

There are clever ways of determining whether a number is a power of 2. That's no longer an interesting problem, so let's determine whether a given integer is an integer power of -2. For example: <...
10
votes
3answers
308 views

Mapping between integer and pronounceable word

Purpose The idea is to provide the code necessary to map a 32-bit integer to/from a pronouncable word of 9 characters maximum. That could be useful, for example, to make a serial number easier to ...
17
votes
13answers
972 views

Integer-Digits of the Arithmetic-Tables

Challenge: Output the 'integer-digits' of one of the following six arithmetic-tables based on the input: - addition (+); - subtraction (...
26
votes
25answers
3k views

Pigeonhole Principle & Code Golf

The pigeonhole principle states that If N items are put into M boxes, with N > M, then at least one box must contain more than one item. For many, this principle has a special status compared to ...
2
votes
0answers
76 views

Storing an array of Integers to WOM [closed]

Very few, if any, programs or applications have utilised the proposed spec for WOM which was initially thought up in the early 1970s as a polar opposite to ROM, so your task is to take a dataset of n ...
11
votes
18answers
644 views

Sort and Re-apply Deltas of an Array

It seems that any Simple Modification of deltas using a consistent function can almost always be done some other shorter way, Dennis. Thus, the only solution I can imagine to make this harder, is to ...
34
votes
64answers
4k views

Output the missing integer

You will be given a string. It will contain 9 unique integers from 0-9. You must return the missing integer. The string will look like this: ...
7
votes
10answers
453 views

How much does this Integer score?

The Challenge Given an integer, calculate its score as described below. The score is calculated by raising each digit of the input Integer to the power n, where <...
13
votes
3answers
453 views

Compute the most efficient binary function

Today, we'll be computing the most efficient binary function. More specifically, we'll be computing the function which, when an expression is created from applying the function to the constant input 0 ...
36
votes
26answers
5k views

Oddly Even, Positively Negative

Given N, output the Nth term of this infinite sequence: -1 2 -2 1 -3 4 -4 3 -5 6 -6 5 -7 8 -8 7 -9 10 -10 9 -11 12 -12 11 ... etc. N may be 0-indexed or 1-...
29
votes
16answers
1k views

Fill in an increasing sequence with as many numbers as possible

A list of numbers is called monotonically increasing (or nondecreasing) is every element is greater than or equal to the element before it. For example, ...
27
votes
10answers
3k views

Solve an equation with (almost) any numbers you like

Given a string of the characters +=- where there is at least one =, insert positive integers between all the symbols and at the ...
62
votes
47answers
6k views

N-dimensional N^N array filled with N

In: Enough memory and a positive integer N Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by... Examples: 1: [1] ...
26
votes
11answers
2k views

Bitflip-resistant composite numbers

Sometimes, when writing a program, you need to use a prime number for some reason or other (e.g. cryptography). I assume that sometimes, you need to use a composite number, too. Sometimes, at least ...
17
votes
11answers
2k views

Find Recursively Prime Primes

The Recursively Prime Primes is are sequence of primes such that p(1) = 2 p(n) = the p(n-1)th prime Here is an example of how one might calculate the 4th ...