# Questions tagged [integer]

For challenges involving the manipulation of integers.

372 questions
Filter by
Sorted by
Tagged with
3k 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 based ...
3k views

### "-rot" transform

Background -rot transform (read as "minus-rot transform") is a sequence transformation I just invented. This transform is done by viewing the sequence as a stack in Forth or Factor (first ...
2k views

### Generate this number table

Given an integer $1 < n < 10$ generate a table like below. For $n = 5$, 1 2 3 4 5 2 2 3 4 5 3 3 3 4 5 4 4 4 4 5 5 5 5 5 5 For $n = 8$, ...
8k views

### Output the sign

Given a number N, output the sign of N: If N is positive, output 1 If N is negative, output -1 If N is 0, output 0 N will be an integer within the representable range of integers in your chosen ...
1k views

### Minimally prepend numbers to get a symmetric Young diagram

Background A Young diagram is a diagram that represents a nonincreasing sequence of positive integers using left-justified rows of squares. As an example, 5, 4, 1 ...
207 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 ...
6k views

### Reduce a number by its largest digit

Task: Given an integer number in decimal number system, reduce it to a single decimal digit as follows: Convert the number to a list of decimal digits. Find the largest digit, D Remove D from the ...
2k views

### Print a conversion table for (un)signed bytes

Your task: Print or return a conversion table with every byte from 00 to ff's value as an unsigned integer, to its value as a ...
3k views

### Longest Zero Sum Sub-array

Given an array of integers. Find out its longest sub-array (contiguous subsequence) whose sum is 0. The sub-array for output may be an empty array. Input Input an array of integers. Output Output the ...
904 views

### Boustrophedon transform

Related: Boustrophedonise, Output the Euler Numbers (Maybe a new golfing opportunity?) Background Boustrophedon transform (OEIS Wiki) is a kind of transformation on integer sequences. Given a sequence ...
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:  ...
2k views

### 2 factors factorization

Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve ...
2k 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 ...
2k views

### Make an array of 128 bit integers

Given an input value $n$, construct an array of $n$ random 128 bit (unsigned) integers. The integers should be uniformly random. Your code can use any in built random number generation function ...
306 views

### Hexagonal section numbers

Introduction Let's draw some regular hexagons formed by hexagonal tiles, marking the vertices of the tiles with dots. Then we will count the number of dots. ...
2k 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

### Maximum number of squares touched by a line segment

Consider a square grid on the plane, with unit spacing. A line segment of integer length $L$ is dropped at an arbitrary position with arbitrary orientation. The segment is said to "touch" ...
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 ...
532 views

### Calculate the integer square root of a matrix

Let $A$ be a square matrix that is at least $2 \times 2$ where each element is an integer. $A^2 = A \times A$ will then have the same dimensions as $A$, and will have integer elements. For ...
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 ...
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 ...
1k views

### Compare positions of integers in this sequence

A001057 is one way to represent an integer as a natural number. It lists them according to the following pattern: 0, 1, -1, 2, -2, 3, -3, 4, -4, ... In this ...
205 views

5k views

### Is it a whole number?

A number is whole if it is a non-negative integer with no decimal part. So 0 and 8 and ...
2k views

### Gödel numbering of a string

Background Gödel numbers are a way of encoding any string with a unique positive integer, using prime factorisations: First, each symbol in the alphabet is assigned a predetermined integer code. Then, ...
9k views

### Stay away from zero

Task Given a non-negative integer n, output 1 if n is 0,...
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 = ...
2k views

### Ken Iverson’s Favourite APL Expression?

Ken Iverson, 1920–2020 Let's implement his favourite expression: Given a row of Pascal's triangle, compute the next row. This can for example be computed by taking the input padded with a zero on the ...
2k views

### Implement a zipwith function

zipwith is a functional construct that takes three arguments: one binary function and two lists of the same length, and returns a single list where each element is ...
Let $A$ be a positive integer consisting of $n$ decimal digits $d_1,d_2,...,d_n$. Let $B$ be another positive integer. For the purpose of this challenge, we call $A$ a copycat of $B$ if ...