Skip to main content

Questions tagged [integer]

For challenges involving the manipulation of integers.

9 votes
4 answers
230 views

A math teacher wants to give his students an interesting geometry problem. He has the following idea (Fig. 1): Let \$AB\$ and \$CD\$ be two chords of a circle with center \$M\$, intersecting ...
Glory2Ukraine's user avatar
14 votes
13 answers
632 views

In the Cortex Prime roleplaying game system, successes and failures are determined by rolling a pool of polyhedral dice of different sizes. After rolling the dice: First, the player chooses two of ...
DLosc's user avatar
  • 41k
16 votes
25 answers
2k 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
18 votes
32 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
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
90 votes
201 answers
12k views

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 ...
user avatar
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
12 votes
12 answers
809 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,115
35 votes
98 answers
9k views

Task Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program. Example with ...
LeopardL GD's user avatar
11 votes
11 answers
965 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,115
72 votes
177 answers
13k views

Write a program or function which will provably print all integers exactly once given infinite time and memory. Possible outputs could be: ...
Fatalize's user avatar
  • 39.6k
57 votes
172 answers
13k views

Task Given a non-negative integer n, output 1 if n is 0,...
Leaky Nun's user avatar
  • 50.7k
12 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
33 votes
26 answers
9k views

Recently (okay, December 2023, I'm a little late) there's been a meme going around about a program checking if a 32-bit unsigned integer is even or odd using four billion if statements: ...
emanresu A's user avatar
  • 46.8k
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

15 30 50 per page
1
2 3 4 5
31