Skip to main content

Questions tagged [integer]

For challenges involving the manipulation of integers.

18 votes
8 answers
1k views

Introduction: When saying numbers out loud, the order is slightly different in Dutch than in English. For a number like \$1234\$: in English you'd say: one thousand, two hundred and thirty-four in ...
Kevin Cruijssen's user avatar
15 votes
18 answers
1k views

This is a sequel to Numbers Interpreted in Smallest Valid Base. Let us define the operation of rebasing a number as writing out its digits in decimal form, then interpreting them in the smallest base <...
SquareFinder's user avatar
20 votes
31 answers
2k views

Let us define the operation of rebasing a number as writing out its digits in decimal form, then interpreting them in the smallest base N possible (...
SquareFinder's user avatar
12 votes
12 answers
747 views

Challenge: Given inputs \$i\$ and \$n\$, calculate \$R_i(n)\$ where: $$R_0(n)=n \\ R_i(n)=\sum_{j=0}^nR_{i-1}(j)$$ Note that \$R_1\$ is triangular function, and \$R_2\$ is tetrahedral function. This ...
Fmbalbuena's user avatar
  • 5,085
10 votes
2 answers
370 views

Task: Your task is make a program to check if there exists integers \$a \ge 2, b \ge 2\$ such that \$a^b=i\$ where \$i\$ is the input integer at least 2. The catch is that your program must return a ...
Fmbalbuena's user avatar
  • 5,085
11 votes
11 answers
794 views

Challenge: Find integers \$a\$ and \$b\$ defining linear function \$f(x) = ax + b\$ with \$a > 0, b \ge 0\$ such that the sum of the elements of the input list \$l\$ located at the values of the ...
Fmbalbuena's user avatar
  • 5,085
18 votes
30 answers
2k views

Given X>0, return the smallest Y>=0 such that X+Y is a palindrome. Code golf. Tests: 5 => 0 14 => 8 200 => 2 819 => 9 1100 => 11 1122 => 99
Steve Bennett's user avatar
13 votes
9 answers
2k views

Over on Puzzling a couple years ago, Hermant Agarwal proposed the following question: In a certain country the following coins are in circulation: 1 cent, 2 cents, 5 cents, 10 cents, 20 cents, 50 ...
caird coinheringaahing's user avatar
2 votes
13 answers
679 views

Task: Write a code golf program that, given two positive integers n and m, returns a list of the distances between consecutive prime numbers in the range [n, m] ...
JuanCa's user avatar
  • 361
19 votes
12 answers
1k views

Definition A Dyck path of length \$2n\$ can be defined as a two-dimensional path such that: The path consists of straight lines of equal length. The path goes left to right while moving either up or ...
Luis Mendo's user avatar
  • 107k
3 votes
1 answer
303 views

Challenge We define a Minsky machine as a program made of the following two instructions: +X which increments the register X and continues to the next instruction -Xn which simply continues if X is ...
malediscord kitten's user avatar
4 votes
4 answers
589 views

Your task is to find a boolean expression that uses AND (\$\land\$), OR (\$\lor\$), XOR (\$\oplus\$), and NOT (\$\lnot\$) operators and binary digit positions (\$d_1,d_2,d_3,d_4,d_5,d_6,d_7,d_8,d_9,d_{...
Fmbalbuena's user avatar
  • 5,085
-5 votes
4 answers
205 views

Determine if a rational number is also an integer, without any form of dividing. The input should be any pair of numerator and denominator. Don't forget to consider negative numbers, and division by ...
Gabriel Tellez's user avatar
7 votes
1 answer
356 views

We learned many identities involving addition, multiplication and exponentiation in highschool, for example: $$ \begin{aligned} (a+b)c &= ac + bc \\ (a b)^c &= a^c b^c \\ (a^b)^c &= a^{bc} ...
Trebor's user avatar
  • 805
16 votes
21 answers
2k views

ZigZag encoding is a method of encoding signed integers to unsigned integers. Non-negative integers are multiplied by two. Negative integers are equal to their absolute values multiplied by two, minus ...
Jordan's user avatar
  • 11.9k

15 30 50 per page
1
2 3 4 5
31