Questions tagged [integer]

For challenges involving the manipulation of integers.

Filter by
Sorted by
Tagged with
19
votes
16answers
2k views

A Portuguese sequence of integers

Context Consider the following sequence of integers: $$2, 10, 12, 16, 17, 18, 19, ...$$ Can you guess the next term? Well, it is \$200\$. What about the next? It is \$201\$... In case it hasn't become ...
14
votes
20answers
2k views

We're all unique in our own way

This is an answer-chaining challenge where every part of your answer should aim to be unique from every other answer. This question will work in the following way: I will post the first answer. The ...
20
votes
42answers
3k views

Converting Strings to Decimals (Gone Wrong)

What? Many programming languages, both practical and esoteric, have functions, methods, etc to convert a given string to a decimal number. This is how the process might work: For each character in ...
17
votes
13answers
938 views

Find all integer pairs that produce a given Loeschian number

Inspired by and drawns from Is this number Loeschian? A positive integer \$k\$ is a Loeschian number if \$k\$ can be expressed as \$i^2 + j^2 + i\times j\$ for \$i\$, \$j\$ integers. For example, ...
14
votes
4answers
393 views

Bad matrix multiplication that gives the right answer

Executive summary: Print NxN matrices \$A\$ and \$B\$ where \$ AB = 10A + B \$. Largest N wins! Details: Entrants in this challenge should choose an N. Submit a program that takes an input integer '...
11
votes
1answer
374 views

Amount Of Potential Keys That'll Fit The Lock

Introduction: You're a key maker, and want to access something from a safe that has a lock. Unfortunately, the key to that lock is lost, so you'll have to make a new one. You have access to a bunch of ...
25
votes
16answers
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 ...
19
votes
16answers
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. ...
4
votes
5answers
215 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 ...
21
votes
6answers
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 ...
12
votes
3answers
695 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 ...
0
votes
2answers
181 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 ...
22
votes
23answers
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}|\$ ...
18
votes
22answers
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 ...
11
votes
10answers
2k views

Integers in cosine

Integers in cosine From trigonometry we know that \$\sin(a) =-\cos(a + \frac{(4*m + 1)\pi}{2})\$ where \$a\$ is an angle and \$m\in\mathbb{Z}\$ (integer). The task For an input of a positive integer \$...
9
votes
8answers
639 views

Perfect scores in Martian rules football

Story Martians have been observing Aussie rules football matches from space with great curiosity. Having totally fallen in love with the game, they have been inspired to start their very own football ...
20
votes
14answers
2k views

Donation arms race

The barfoos, a hypothetical alien species, go about charity in an interesting way. Every morning, barfoo Specialists come up with an ordered list of causes to donate to, and for each cause they ...
17
votes
9answers
2k views

Missile-mounted cameras

You are employed as Administrator in charge of Road Maintenance and Planning. The intelligence division of the Agency for Road Maintenance and Planning has come up with a brilliant and not at all ...
15
votes
43answers
2k views

Generate list of numbers and their negative counterparts

A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python. Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$...
17
votes
5answers
881 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. ...
50
votes
31answers
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 ...
17
votes
3answers
673 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 ...
21
votes
17answers
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) ...
24
votes
9answers
840 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 ...
15
votes
14answers
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 ...
25
votes
21answers
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 ...
12
votes
4answers
431 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\$ ...
19
votes
24answers
2k views

A bit of a digital XOR

Here are the first 100 numbers of a sequence: ...
17
votes
20answers
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 ...
29
votes
46answers
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 ...
15
votes
23answers
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 ...
9
votes
5answers
487 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 ...
34
votes
45answers
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 ...
38
votes
13answers
3k views

Phony fractions

Context If a0 and b0 are two decimal numbers, with a and ...
2
votes
5answers
172 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: ...
12
votes
9answers
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 ℚ \\...
37
votes
38answers
8k views

Is this a triangle?

Task Write a function/program that, given three positive integers a, b and c, prints a ...
25
votes
25answers
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 ...
21
votes
25answers
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: ...
15
votes
16answers
2k 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 ...
33
votes
5answers
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'...
5
votes
15answers
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 ...
20
votes
9answers
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. ...
22
votes
40answers
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 = ...
16
votes
16answers
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 ...
25
votes
7answers
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: ...
1
vote
0answers
74 views

Making Fibonacci Cry [duplicate]

Introduction The Fibonacci sequence is a mathematical sequence in which each term is the sum of the \$2\$ terms before it; the first two terms are \$0\$ and \$1\$. The first few terms are \$0, 1, 1, ...
1
vote
20answers
509 views

Quine in Bytes, not Characters [duplicate]

Introduction A quine is a program that takes no input and produces a copy of its own source code as output. Writing a quine is a standard test of a programming language. Most quines operate using ...
19
votes
25answers
4k views

Visualize a large int

Convert a large int (e. g. 1234567890) into a string containing the usual decimal prefixes k, M, G, T, etc. for kilo, mega, giga, tera, etc. The result shall be groups of three digits, interspersed ...
13
votes
35answers
2k views

Determine the Winner of a Game of Australian Football

In Australian Football, goals are worth 6 points and behinds are worth 1 point. Scores may include the number of goals and behinds, as well as the total score. Given the number of goals and behinds ...

1
2 3 4 5
7