Questions tagged [integer]

For challenges involving the manipulation of integers.

Filter by
Sorted by
Tagged with
-4
votes
11answers
2k views

I'm stepping down

You are given 4 positive integers: volume of the first container (v1), volume of the second container (v2), volume of the liquid ...
47
votes
23answers
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 ...
16
votes
10answers
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: ...
19
votes
27answers
2k 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 ...
14
votes
8answers
918 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 ...
41
votes
121answers
9k views

Stay away from zero

Task Given a non-negative integer n, output 1 if n is 0,...
18
votes
9answers
1k 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. ...
20
votes
38answers
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 = ...
15
votes
48answers
2k views

Print the Lost numbers

As a big fan of the Lost TV series, I always got intrigued by the sequence of numbers that repetitively appears on the episodes. These numbers are: \$ 4, 8, 15, 16, 23, 42\$ (A104101) Using any ...
51
votes
128answers
8k 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: ...
13
votes
1answer
301 views

Decompose Commutators

A theorem in this paper1 states that every integral n-by-n matrix M over the integers with trace M = 0 is a commutator, that means there are two integral matrices A,B of the same size ...
34
votes
68answers
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: ...
15
votes
5answers
765 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 <...
15
votes
16answers
910 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 ...
12
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 ...
23
votes
8answers
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: ...
26
votes
19answers
2k views

Crown hundred crownty crown

I noticed a certain game had a peculiar life counter, which instead of stopping at 999, gained a new digit – the next number was crown hundred or ...
11
votes
6answers
917 views

Group Integers by Originality

Introduction: I collect twisty puzzles. Most twisty puzzles are produced and sold by Chinese companies. Most well-known companies ask permission from puzzle designers to produce their designs and ...
25
votes
33answers
3k views

Triangular Dependencies

A triangular number is a number that is the sum of n natural numbers from 1 to n. For example ...
0
votes
0answers
68 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, ...
18
votes
30answers
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 ...
0
votes
20answers
454 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 ...
26
votes
15answers
2k views

Toggle some bits and get a square

Given an integer \$N>3\$, you have to find the minimum number of bits that need to be inverted in \$N\$ to turn it into a square number. You are only allowed to invert bits below the most ...
18
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 ...
28
votes
29answers
4k views

Inverse Colombian Function

Let's define a sequence: The n digit summing sequence (n-DSS) is a sequence that starts with n. If the last number was k, then the next number is k + digit-sum(k). Here are the first few n-DSS: ...
46
votes
27answers
2k views

Divisor skyline

For any positive integer k, let d(k) denote the number of divisors of k. For example, ...
15
votes
16answers
937 views

Length of a UTF-8 byte sequence

Determine the length of a UTF-8 byte sequence given its first byte. The following table shows which ranges map to each possible length: ...
23
votes
39answers
4k 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 ...
31
votes
29answers
5k views

Double it your way

There have been a couple of challenges involving doubling source code: here and here. The task we have here is a bit harder, but should be doable in almost every language. In this challenge, you will ...
41
votes
39answers
3k views

An Array of Challenges #1: Alternating Arrays

Alternating Arrays An alternating array is a list of any length in which two (not necessarily different) values are alternating. That is to say, all even-indexed items are equal, and all odd-indexed ...
18
votes
20answers
5k views

Simplistic Lava Lamp

Introduction: I think everyone knows what a Lava Lamp is, but in case they do not: (Image source) They're basically glass tubes that contain wax in a translucent liquid. The bottom part is heated ...
26
votes
63answers
4k views

The Non-Zero Digital Product Challenge

Originally the Multiplicative digital root Challenge Basically do what the title says Method Given a positive integer 1 <= N <= 100000000 through one of our standard input methods, multiply ...
26
votes
30answers
3k views

Output with the same length always

With challenges like Output with the same length as the code and Create output twice the length of the code, I thought of a separate, but similar challenge. The task is to produce an output. It can ...
26
votes
17answers
4k views

Infinitely many primes

Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot.....
22
votes
24answers
4k 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.) ...
27
votes
41answers
2k views

Enumerate each series of identical numbers in-place

Given a list of strictly positive integers, go through each distinct number and replace all occurrences of it with successive indices (zero or one based) of a new series. Examples ...
32
votes
23answers
8k views

Could you please stop shuffling the deck and play already?

Challenge: Input: A list of distinct positive integers within the range \$[1, \text{list-size}]\$. Output: An integer: the amount of times the list is riffle-shuffled. For a list, this means the ...
34
votes
35answers
5k views

Repeated! Factorials!

Not to be confused with Find the factorial! Introduction The factorial of an integer n can be calculated by $$n!=n\times(n-1)\times(n-2)\times(...)\times2\times1$$...
31
votes
41answers
3k views

Find the sum of all numbers below n that are a multiple of some set of numbers

Almost equivalent to Project Euler's first question: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find ...
37
votes
27answers
4k views

Cops: The Hidden OEIS Substring

This is a Cops and Robbers challenge. This is the cop's thread. The robber's thread is here. As a cop, you must pick any sequence from the OEIS, and write a program p that prints the first integer ...
19
votes
17answers
2k views

Find Integral Roots of A Polynomial

Challenge The challenge is to write a program that takes the coefficients of any n-degree polynomial equation as input and returns the integral values of x for which the equation holds true. The ...
26
votes
54answers
6k views

Integer Lists of Noah

Introduction: I think we've all heard of it, but here a very brief summary: Noah gathered two of every species of animal on the planet, male and female, to save in his Ark during a great flood. The ...
27
votes
13answers
3k views

Valid Badminton Score?

Introduction: I saw there was only one other badminton related challenge right now. Since I play badminton myself (for the past 13 years now), I figured I'd add some badminton-related challenges. ...
23
votes
24answers
3k views

Robbers: The Hidden OEIS Substring

This is a Cops and Robbers challenge. This is the robber's thread. The cop's thread is here. The cops will pick any sequence from the OEIS, and write a program p that prints the first integer from ...
28
votes
16answers
2k views

Output the Euler Numbers

Given a non-negative integer \$n ,\$ output the \$n^{\text{th}}\$ Euler number (OEIS A122045). All odd-indexed Euler numbers are \$0 .\$ The even-indexed Euler numbers can be computed with the ...
20
votes
17answers
2k views

Square Root Distance from Integers

Given a decimal number k, find the smallest integer n such that the square root of n is ...
58
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
4answers
430 views

Find X,Y,Z coordinates from index

Introduction I began studying the Collatz Conjecture And noticed these patterns; 0,1,2,2,3,3...A055086, and 0,1,2,0,3,1...A082375, in the numbers that go to 1 in one odd step, 5,10,20,21,40,42......
2
votes
3answers
115 views

Sum of multiples of powers of ten of an integer [duplicate]

Write a function to produce, for a non-negative integer, a string containing a sum of terms according to the following: ...
37
votes
31answers
14k views

Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?

Introduction: A few days ago I read this post with the same title when I came across it in the HNQ. In this question it is being discussed if the claim of president-candidate Bernie Sanders, who ...