# Questions tagged [integer]

For challenges involving the manipulation of integers.

326 questions
Filter by
Sorted by
Tagged with
3k views

### A long long time ago, in a galaxy … right here

Task Given a positive integer return the geologic era and period it was that many million years ago. Input/output The input is a string or integer; the output is a string. Eras and periods are ...
2k views

### Find the discrete logarithm

Task Write a program/function that when given 3 positive integers $a, b$ and $m$ as input outputs a positive integer $x$ such that $a^x\equiv b\ (\text{mod}\ m)$ or that no such $x$ exists. ...
210 views

### Divide into 2 isosceles triangles

Given the measures of two of the interior angles of a triangle (x and y; the other angle can be easily calculated with ...
2k views

### The matrix has U

Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as ...
679 views

### Metagolf the OEIS

We've had Meta Regex Golf and Display OEIS Sequences. Now, it is time for Meta OEIS Golf. Challenge Given a sequence of integers, your program/function should output a program/function in the same ...
178 views

### Remove each integer from a string and multiply them all! [closed]

Goal: Get every integer from the string (not a number, but integer) Multiply them Output the result Input: 5 kilograms of food eaten, 10 liters of water drank, 20 plates dirty, 40 mugs dirty, and ...
1k views

### Complete a sequence using its distances

Given $A = (a_1,\dots,a_k)\ k\ge2$ a sequence of positive integers, in which all elements are different. Starting from $i=2$, while $a_i\in A:$ (until the last element) If $d=|a_i-a_{i-1}|$ ...
2k views

### Zero the byte (eventually)

Given an infinite arithmetically-progressive¹ sequence, compute the minimum length of a prefix with a product divisible by 2^8. Sample cases & reference implementation Here is a reference ...
2k views

870 views

### Generate Green Spray Paint Patterns

This challenge is about creating these neat "green spray paint" patterns: (more pictures below) Loosely explained, they are generated by starting with a black image and a point in the center. ...
7k views

### Conway's Monster

This challenge is in honor of mathematician John Conway who passed away April 11, 2020 due to COVID-19. He was famous for coming up with the Game of Life cellular automaton and many other mathematical ...
665 views

### Make a rectangle from a collection of (sliced) squares

Inspired by Make a Rectangle from a Triangle. Task There is a famous formula on the sum of first $n$ squares: $$1^2 + 2^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6}$$ It is known that this number ...
3k views

### Make a Rectangle from a Triangle

You can depict a triangular number, T(N), by writing one 1 on a line, then two 2's on the line below, then three 3's on the line below that, and so on until N N's. You end up with a triangle of T(N) ...
836 views

### Maintain diagonal symmetry when placing N items on a square grid

Write a program that takes in two non-negative integers S and N in that order. S represents the side length of a square grid of . characters. N represents the ...
1k views

### Generating generating expressions for sequences

(yes, "generating generating" in the title is correct :) ) Context In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the ...
2k views

### Four distinct 8-bit integers

Submit a well-formed program or function with usual I/O rules which satisfy the input, output, and algorithm conditions below. Shortest submission (in bytes) wins. As always, standard loopholes are ...
427 views

### Solving the water bucket riddle!

Context The water buckets riddle or the water jugs riddle is a simple riddle that can be enunciated in a rather general form as: Given $n > 0$ positive integers $a_1, a_2, \cdots, a_n$ ...
2k views

### A bit of a digital XOR

Here are the first 100 numbers of a sequence: ...
2k views

### All aboard the factorial train

The system Assume the Earth is flat and that it extends infinitely in all directions. Now assume we have one infinitely long train railway and n trains in that ...
5k views

### How many petals around the rose

How many petals around the rose How many petals around the rose is a dice game you can play with your friends. Similar to "can I join the music box", there is a person that knows how the ...
2k views

### Summing a sub-square of a quarter of an infinite chessboard

Description of the problem Imagine a quarter of an infinite chessboard, as in a square grid, extending up and right, so that you can see the lower left corner. Place a 0 in there. Now for every other ...
484 views

### Computing a specific coefficient in a quotient of polynomials

Context After "Computing a specific coefficient in a product of polynomials", asking you to compute a specific coefficient of polynomial multiplication, I wish to create a "mirror" challenge, asking ...
3k views

### (RGS 1/5) Binary multiples

A binary multiple of a positive integer k is a positive integer n such that n is written ...
3k views

### Phony fractions

Context If a0 and b0 are two decimal numbers, with a and ...
170 views

### Shift the digits [closed]

Here, x (supplied as input) and n (the result of your computation) are both positive integers. n * x = n shifted. Find n. Here's an example of shifting: ...
1k views

### Integer Logarithm

Objective Take $a \in ℤ_{>1}$ and $b \in ℤ_+$ as inputs. Write a function $f$ such that:  f(a,b) = \left\{ \begin{array}{ll} \log_ab & \quad \text{if} \space \log_ab \in ℚ \\...
8k views

### Is this a triangle?

Task Write a function/program that, given three positive integers a, b and c, prints a ...
2k views

### Mountain range numbers

Mountain range number A number is a mountain range number if the inequalities satisfied by their consecutive digits alternate. In a way, looking at the number's digits should exhibit a ...
2k views

### Power-Ending Patterns

When you look at the last decimal digit of each power of a non-negative integer a repeating pattern forms. For example, 3: ...
1k views

### Computing a specific coefficient in a product of polynomials

Generator functions This gives the context for why this challenge came to life. Feel free to ignore. Generator functions are a nice way of encoding the solution to a problem of combinatorics. You ...
2k views

### Make The Finest Magic Code Square

In math a magic square is an N×N grid of numbers from 1 to N2 such that every row, column, and diagonal sums to the same total. For example here's a 3×3 magic square: In this challenge we'...
3k views

### Move my liquid to make me equal

You are given 4 positive integers: volume of the first container (v1), volume of the second container (v2), volume of the liquid ...
2k views

### Proportion of self-avoiding walks on a square lattice

The challenge Given a positive integer N, compute the proportion of N-step walks on a plane that don't intersect themselves. ...
4k views

### Round up my number

Sandbox Given two positive integers a and b, return the smallest multiple of b that is greater than or equal to a. Examples Definitions: true = ...
1k views

### Find the length of a number's “base-jumping” path

Consider a positive integer N written in base b. A sequence is generated from this number by finding the largest digit ...
2k views

### Inverse Look-and-Say

Background The Look and Say Sequence is built up by reading off the digits of previous entries in the sequence, counting the number of digits in groups of the same digit. For example: ...
72 views

5k views

### Count the number of triangles

Given a list of positive integers, find the number of triangles we can form such that their side lengths are represented by three distinct entries of the input list. (Inspiration comes from CR.) ...
2k views

### Numbers Decrease while Letters Increase

Randomly inspired by Numbers Increase While Letters Decrease Given a list of mixed letters and integers (e.g., ['a', 2, 3, 'b']) increase the letters by one ...