For challenges involving the manipulation of integers.

learn more… | top users | synonyms

15
votes
12answers
897 views

Plus and Times, Ones and Nines

Implement this recurrence relation as a function or program that inputs and outputs a non-negative integer: F(0) = 0 F(N) = the smallest integer greater than F(N-1) such that the sum and/or product ...
-1
votes
0answers
65 views

Convert a bit into a bool - or more bits? [on hold]

Preamble We all know the datatype bool. It is common in many languages, and the easiest way to represent a bool as a number is either 1 or 0. Therefore, a boolean can contain two values: 1, true, or ...
17
votes
12answers
516 views

Transpile WordMath

We've all seen those online "maths hax" that look like this: Think of a number, divide by 2, multiply by 0, add 8. And, by magic, everyone ends up with the number 8! Language Let's define a ...
17
votes
21answers
1k views

Reverse Deltas of an Array

Reverse Deltas of an Array A continuation of Inverse Deltas of an Array Your task is to take an array of signed 32 bit integers, recompile it with its deltas reversed. Example The List, 18 19 ...
20
votes
7answers
786 views

Numpad Word Search

Given an integer from 1 to 999 inclusive, output a truthy value if it appears horizontally, vertically, or diagonally, either forwards or backwards, anywhere in the 3x3 square of digits 1-9 on a ...
31
votes
17answers
2k views

Complex Binary Numbers

Let's create a simple, surjective mapping from positive integers to Gaussian integers, which are complex numbers where the real and imaginary parts are integers. Given a positive integer, for example ...
27
votes
42answers
2k views

The Squaring Sequence

Each term in the squaring sequence, xn, is created by taking xn-1, squaring it, and removing all but the first four digits. The sequence always begins with x1 = 1111. Squaring this yields 1234321, ...
19
votes
7answers
1k views

Alphabetize Integers

Alphabetize Integers For a given set of numbers, put them in alphabetical order when they are spelled out (i.e. 1: one, 2: two, 90: ninety, 19: nineteen). Your code should work for the range [-999999,...
36
votes
28answers
3k views

Increment an Array

Given a nonempty array of positive integers, "increment" it once as follows: If all the array elements are equal, append a 1 to the end of the array. For example: [1] -> [1, 1] [2] -> [2, 1] [...
14
votes
9answers
729 views

All the Xenodromes

Introduction A xenodrome in base n is an integer where all of its digits in base n are different. Here are some OEIS sequences of xenodromes. For example, in base 16, FACE, 42 and FEDCBA9876543210 ...
16
votes
24answers
1k views

Inverse Deltas of an Array

Inverse Deltas of an Array Your task is to, given an array of signed 32 bit integers, recompile it with its inverse deltas. For example, the list 1 3 4 2 8 holds the deltas: 2 1 -2 6 ...
29
votes
27answers
3k views

Let's decrease the monotony

...but hey, no need to be strict. Given a non-empty array of strictly positive integers, determine if it is: Monotone strictly decreasing. This means that each entry is strictly less than the ...
11
votes
5answers
440 views

Find the Emirps!

An emirp is a non-palindromic prime which, when reversed, is also prime. The list of base 10 emirps can be found on OEIS. The first six are: 13, 17, 31, 37, 71, 73 However, due to the reversal ...
12
votes
4answers
352 views

Binary Convolution

A binary convolution is described by a number M, and is applied to a number N. For each bit in the binary representation of M, if the bit is set (1), the corresponding bit in the output is given by ...
18
votes
21answers
1k views

Binary Countdown Length

inspired by Count down from infinity Given a non-negative integer N, output the number of repetitions of the following steps it takes to reach 0: Convert N to binary (4812390 -> ...
12
votes
19answers
2k views

Produce Dürer's magic square

The challenge Output an array or string representation of DĂĽrer's famous magic square: that is, 16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1 Some properties of this square, which can perhaps be ...
27
votes
17answers
3k views

Draw an ASCII-O'-Lantern for Halloween

Halloween is almost here, the holiday after which most people need to wean themselves off a hollow diet of sugar. Write a program that takes in a positive integer. If the integer is less than 31 (1 ...
21
votes
28answers
1k views

Least Common Multiple

The least common multiple of a set of positive integers A is the smallest postive integer B such that, for each k in A, there exists a positive integer n such that k*n = B. Given at least two ...
17
votes
8answers
875 views

Prime factors buddies

Given an integer N > 1, output all other numbers which prime decompositions have the same digits as the prime decomposition of N. For example, if N = 117, then the output must be [279, 939, 993, ...
26
votes
85answers
5k views

Print all integers

Write a program or function which will provably print all integers exactly once given infinite time and memory. Possible outputs could be: 0, 1, -1, 2, -2, 3, -3, 4, -4, … 0, 1, 2, 3, 4, 5, 6, 7, ...
45
votes
20answers
4k views

Greater than less than greater than something fishy

Given a length N string of less-than and greater-than signs (<, >), insert the integers 0 through N at the start and end and in between each pair of signs such that all the inequalities are ...
25
votes
49answers
3k views

As Easy as One-Two-Three

Write a program or function that takes in a positive integer. You can assume the input is valid and may take it as a string. If the number is any of 123 234 345 456 567 678 789 then output a truthy ...
17
votes
15answers
2k views

Write a program that outputs the number of times it has been run [duplicate]

In a programming language of your choice, write a full program that, when run, prints a positive integer N and then modifies its own source file such that the next time it is run it will print N+1. ...
22
votes
33answers
2k views

Where are Champernowne's zeroes?

Consider the infinite string of all nonnegative decimal integers concatenated together in order (akin to Champernowne's constant): 0123456789101112131415161718192021222324252627282930......
18
votes
32answers
3k views

Smallest palindrome divisible by the input

Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by N. The palindrome (i.e. the output) must not need ...
15
votes
20answers
1k views

Smallest positive number whose y-th power is divisible by x

Task Given integers x and y which are both at least 2, find the smallest positive number whose y-th power is divisible by x. Example Given x=96 and y=2, the output should be 24 since 24 is the ...
5
votes
8answers
483 views

Smallest positive integer not yet appeared so that the sum of the first n elements is divisible by n

Task Given positive integer n, output a(n) where a is the sequence defined below: a(n) is the smallest positive integer not yet appeared so that the sum of the first n elements in the sequence is ...
12
votes
5answers
359 views

A047841: Autobiographical numbers

Definition Here is the process to describe a number: For each number from 0 to 9 that is present in the number: Write down the frequency of that digit and then the digit. For example, for the ...
16
votes
9answers
2k views

Integer goes back and forth through time

Input: An integer. Output: First convert the integer to it's equivalent Roman Numeral. Then convert each capital letter of that Roman Numeral to their ASCII/UNICODE decimal value. And output the ...
2
votes
5answers
227 views

“Break” a number [closed]

Origins tl;dw (too lazy, didn't write): thought of it right before I fell asleep Challenge Breaking a number is defined as the following steps: Take a number or a parseable data type as input in ...
1
vote
3answers
274 views

The fastest square root calculator [closed]

Write a program which outputs the square root of a given number in the shortest time possible. Rules It may not use any builtins or powering with numbers between 0 and 1. Input format as a ...
17
votes
29answers
2k views

Calculate the sum of ILD

Input: An integer Output: Sum of the input itself + the length of the input + each individual digit of the item. nr + nr-length + {sum of individual digits} = output For example: Input: 99 ...
7
votes
8answers
499 views

Excludivisible numbers

Given an integer N, output the Nth positive number K with the following property in decimal base: For each digit I at position P of K, the number formed from K by removing the Pth digit (i.e. I) is ...
32
votes
4answers
4k views

The happy Ender problem

The happy ending problem (actually a theorem) states that Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral. The ...
14
votes
24answers
1k views

Separate alphabets and numbers

A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line. Rules:...
8
votes
26answers
2k views

The Nine Pattern

Introduction I stumbled across this (useless) pattern the other day while I was watching TV. I named it "the 9 pattern" because the first number to use it was 9. The gist of it is, you enter a number ...
21
votes
23answers
986 views

Divisor reduction

A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n: n divisors ...
7
votes
20answers
751 views

Briefest code to find vowels and print consonants

Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins! Output must look like this: Enter String: Input Vowel Count: a: ...
1
vote
5answers
114 views

Bijective mapping from integers to a variable number of trits

This challenge is a harder version of this one. A variable number of trits is an array of 0 or more trits (a trit is a ternary digit). So [0, 2, 2, 1] is a variable number of trits, but so is []. ...
19
votes
11answers
1k views

Polynomialception

Given two polynomials f,g of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. f(g(x)) (a.k.a. the composition (fog)(x) of the ...
13
votes
16answers
809 views

Sorting rectangular matrices

Given a matrix A, we can say that it is "sorted" if each row and column of A is sorted (ascending left-to-right for rows and top-to-bottom for columns). Thus, this matrix is sorted: [ 1 2 3 4 5 ] [ 2 ...
38
votes
32answers
6k views

Never tell me the odds

Input A integer n ( ≥ 1) and a digit d (an integer such that 0 ≤ d ≤ 9). In either order; from stdin or parameters or whatever; to a program or function; etc. ...
11
votes
8answers
440 views

Bijective mapping from integers to a variable number of bits

A variable number of bits is an array of 0 or more bits. So [0, 1] is a variable number of bits, but so is []. Write a function or program that, given an nonnegative integer returns a variable number ...
23
votes
6answers
2k views

Big big numbers

Whilst trying to golf several of my answers, I've needed to write large integers in as few characters as possible. Now I know the best way to do that: I'll be getting you to be writing this program. ...
8
votes
3answers
396 views

Summation under Zeckendorf Representation

Zeckendorf's theorem shows that every positive integer can be uniquely represented as a sum of non-adjacent Fibonacci numbers. In this challenge, you have to compute the sum of two numbers in ...
7
votes
3answers
370 views

Integral triangles and integral medians

Consider a triangle ABC where each side has integer length (an integral triangle). Define a median of ABC to be a line segment from a vertex to the midpoint of the opposing side. In the figure below, ...
22
votes
3answers
1k views

Stacking Pythagorean Triangles

Background A Pythagorean triangle is a right triangle where each side length is an integer (that is, the side lengths form a Pythagorean triple): Using the sides of this triangle, we can attach two ...
21
votes
2answers
705 views

Help me procrastinate on my computer repairs!

This challenge is brought to you by real (and tragic) inspiration. Recently, the number row on my keyboard has been a bit sporadic. The keys 1-9 work sometimes--but other times they have no result. As ...