Skip to main content

Questions tagged [integer]

For challenges involving the manipulation of integers.

11 votes
23 answers
922 views

Construct a uInt from an array of bits

Task is simple! Take an array of binary values (can be boolean, 0/1, etc.) and use those bits to construct an n-th bit long unsigned integer (return type does not need to be an unsigned integer, just ...
ThePlaneGuy45's user avatar
15 votes
24 answers
5k views

FizzFizzFizzBuzz!

Given a positive integer n, output the "FizzFizzFizzBuzz" sequence for that number: print the decimal representations of the numbers 1 through ...
3-1-4-One-Five's user avatar
18 votes
13 answers
2k views

Emulate Jelly's tie-scan

The golfing language Jelly has a built-in ƭ called "tie", that cycles through a list of functions every time it's called. For example, ...
emanresu A's user avatar
  • 39.2k
14 votes
14 answers
2k views

Break an integer into even- and odd-indexed bits

Objective Given an integer \$n\$ interpreted as two's complement binary, output two integers, namely the integer consisting of \$n\$'s bits at places of \$2^0, 2^2, 2^4, \cdots\$, and the integer ...
Dannyu NDos's user avatar
  • 5,961
2 votes
3 answers
207 views

Rank poker High Card hands [closed]

In the poker game there are 1277 unique 'High Card' ranks. It's 1287 (13 over 5) if we include all straights. The challenge is to write a function which returns an integer value corresponding to the ...
Ziarek's user avatar
  • 123
14 votes
7 answers
2k views

How quickly can you type this unary string?

If I want to type the string aaa, the least keystrokes I can type it in is 3: a a a. But if I want to type the string ...
emanresu A's user avatar
  • 39.2k
10 votes
5 answers
975 views

Manipulate integers to zero

Objective Given a nonempty unordered list of positive integers, decide whether they can be added, negated, or multiplied to yield a single zero. Each given number must be used exactly once. There is a ...
Dannyu NDos's user avatar
  • 5,961
18 votes
26 answers
2k views

Is it a tetrate of two?

The tetration operation consists of repeated exponentiation, and it is written ↑↑. For instance, 3↑↑3 =3 ^(3^3) = 3^27 = 7,625,597,484,987 A tetrate of two is an ...
isaacg's user avatar
  • 42.1k
17 votes
21 answers
2k views

Divmod continuously until the remainder is 1 or 0, then get the remainder

The task is simple, divide, get the quotient and the remainder, and if the remainder isn't 1 or 0, do the same thing (quotient divmod remainder) until the remainder is 1 or 0, then get the remainder. ...
Fmbalbuena's user avatar
  • 4,167
10 votes
12 answers
1k views

Counting Collinear Points

Given two points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ with integer coordinates, calculate the number of integer points (excluding the given points) that lie on the straight line segment joining these two ...
vengy's user avatar
  • 2,211
4 votes
1 answer
607 views

Which line is best?

Consider an \$n \times n\$ grid of integers. The task is to draw a straight line across the grid so that the part that includes the top left corner sums to the largest number possible. Here is a ...
Simd's user avatar
  • 3,098
18 votes
39 answers
2k views

Rudin-Shapiro sequence

The Rudin-Shapiro sequence is a sequence of \$1\$s and \$-1\$s defined as follows: \$r_n = (-1)^{u_n}\$, where \$u_n\$ is the number of occurrences of (possibly overlapping) \$11\$ in the binary ...
alephalpha's user avatar
  • 48.7k
17 votes
23 answers
2k views

Monotone sequence beatitude

Provided that the input is a monotone sequence of three or more integers: Output -2 if the sequence strictly decreases. Example: [7,4,3,2] Output -1 if the ...
Dannyu NDos's user avatar
  • 5,961
11 votes
8 answers
2k views

Add two natural numbers

Given two natural numbers (less than 100) as input print the sequence of intermediate results obtained when computing the sum of the two numbers using only the following operations1: ...
bsoelch's user avatar
  • 6,035
17 votes
14 answers
2k views

Finding the power sandwich version 2

Introduction This question is inspired by this great question. Challenge Given a number \$N>0\$, output the largest integer \$a^b\$ that is smaller or equal to \$N\$, and the smallest integer \$c^d\...
Dmitry Kamenetsky's user avatar

15 30 50 per page
1
2 3 4 5
30