Questions tagged [sequence]

For challenges involving sequences, typically of numbers following some pattern.

Filter by
Sorted by
Tagged with
-8 votes
1 answer

Shortest code to generate 2D coordinates

I'm looking for the shortest code to generate the following sequences: Sequence A i | y x 0 | 0 0 1 | 0 1 2 | 1 0 3 | 1 1 The best I have is ...
the swine's user avatar
  • 123
19 votes
4 answers

Calculate practical numbers

Definition A positive integer n is a practical number (OEIS sequence A005153) iff all smaller positive integers can be represented as sums of distinct divisors of <...
Peter Taylor's user avatar
  • 43.1k
91 votes
109 answers

4, 8, 15, 16, 23, 42 [closed]

4, 8, 15, 16, 23, 42 Write a program that outputs this sequence of numbers infinitely. However, The Numbers must not appear in your source code anywhere. The following is not a valid Java program to ...
Radiodef's user avatar
  • 2,416
14 votes
15 answers

Point-free look and say sequence [duplicate]

You are too make a program that take an integer as the input and outputs the first what ever that number was of the look and say sequence. For example: ...
Christopher King's user avatar
11 votes
9 answers

Find all Perrin pseudoprimes less than 100 million

Simply put, the Perrin sequence has the following recurrence relation: P(n) = P(n-2) + P(n-3); P(0) = 3; P(1) = 0; P(2) = 2; But wait!! There's more!! The Perrin sequence has a very bizarre property:...
PhiNotPi's user avatar
  • 29.1k
15 votes
16 answers

Write a program which performs brute force letter combination until the word "password" is found

The program should print every letter combination (lowercase or uppercase, it doesn't matter) in alphabetic order. It must start with a and the last printed ...
ST3's user avatar
  • 1,369
87 votes
137 answers

Collatz Conjecture (OEIS A006577)

This is the Collatz Conjecture (OEIS A006577): Start with an integer n > 1. Repeat the following steps: If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. It is proven that ...
Doorknob's user avatar
  • 71.5k
26 votes
11 answers

Flipping pancakes

In pancake sorting the only allowed operation is to reverse the elements of some prefix of the sequence. Or, think of a stack of pancakes: We insert a spatula somewhere in the stack and flip all the ...
daniero's user avatar
  • 18.6k
12 votes
7 answers

Generate Skolem sequences

Skolem sequences A Skolem sequence is a sequence of 2n numbers where every number i between ...
boothby's user avatar
  • 9,786
20 votes
2 answers

The number of possible numeric outcomes of parenthesizations of 2^2^...^2

Consider an expression 2^2^...^2 with n operators ^. Operator ...
Vladimir Reshetnikov's user avatar
24 votes
34 answers

Give the smallest number that has N divisors

Your function takes a natural number and returns the smallest natural number that has exactly that amount of divisors, including itself. Examples: ...
SteeveDroz's user avatar
  • 2,463
8 votes
8 answers

Make a pattern alternate

Problem You are given a sequence of coloured balls (red R and green G). One such possible sequence is: ...
Thomas O's user avatar
  • 3,348
17 votes
3 answers

Longest non-repeating Game-of-Life sequence

Given a positive integer N, determine the starting pattern on a N x N-grid that yield the longest non-repeating sequence under Game of Life-rules, and ends with a fixed pattern (cycle of length 1), ...
Per Alexandersson's user avatar
5 votes
1 answer

Determine the original sequence

Write a program that will determine the original sequence given five variations. The original sequence will be contain n unique elements in any order. A variation is made by making a copy of the ...
miles's user avatar
  • 16.9k
11 votes
21 answers

Return each number from a group of numbers

The challenge The program must return all numbers included into a group (comma and hyphen separated sequence) of numbers. Rules s is the sequence string; all ...
BernaMariano's user avatar
8 votes
2 answers

Quickly find length of n-th term of the look-and-say sequence

The look and say sequence is an example of a run length encoding sequence. To get the next term of the sequence one groups the sequence into runs of the same number, each group in the next term then ...
Soham Chowdhury's user avatar
15 votes
21 answers

Calculate the nth term of Golomb's self-describing sequence

Inspired by the previous question. Golomb's self-describing sequence g(n) is a sequence where any natural number n is repeated within the sequence g(n) times. The ...
beary605's user avatar
  • 4,350
25 votes
11 answers

Generate a Kolakoski sequence [duplicate]

Definition1 A Kolakoski sequence is a self-describing infinite sequence {kn} of alternating blocks of 1's and 2's, given by the following rules: k0 = 1 kn = the length of the (n+1)'th ...
ardnew's user avatar
  • 2,329
3 votes
9 answers

Generate a valid sequence of numbers with specific rules [closed]

The challenge The program must return a valid sequence of numbers into some rules Rules x is the size of the sequence; x ...
BernaMariano's user avatar
14 votes
3 answers

Universal (rule-bending) Code Golf solver

Code golf always involves some answers that bend the rules more or less by breaking constraints that the challengers took for granted or just haven't thought about and didn't list in the rules. One of ...
schnaader's user avatar
  • 1,202
4 votes
21 answers

Arithmetic Sequences

An arithmetic sequence is a sequence of numbers of the form a,a+n,a+2n,...
beary605's user avatar
  • 4,350
30 votes
31 answers

Josephus problem (counting out)

The challenge Write a function that takes two positive integers \$n\$ and \$k\$ as arguments and returns the number of the last person remaining out of \$n\$ after counting out each \$k\$-th person. ...
Howard's user avatar
  • 23.5k
6 votes
13 answers

Generate the list [1, 0, -1, 0, 1, 0, -1, 0, ...] [closed]

In the spirit of a question on given an integer n, return the integer in position n of the sequence [1, 0, -1, 0, 1, 0, ...
Snowball's user avatar
  • 169
2 votes
17 answers

The group of sequential positive numbers with the highest sum?

Given the following list of numbers, find the group of sequential positive numbers with the highest sum. Example input: 12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1 ...
Al Newkirk's user avatar
10 votes
3 answers

Unfolding an integer

Given the functions L: (x, y) => (2x - y, y) R: (x, y) => (x, 2y - x) and a number N generate a minimal sequence of ...
user3130's user avatar
  • 101
15 votes
30 answers

Jolly Jumper Sequence

A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1. So the sequence [4,1,2,4] has absolute ...
eternalmatt's user avatar
16 votes
7 answers

What comes next?

Given a space-separated list of integers, your task is to find the next integer in the sequence. Each integer in the sequence is the result of applying a single mathematical operation(...
Gareth's user avatar
  • 11.4k
27 votes
22 answers

Code Golf: 6174 - Kaprekar's mythical constant

Why is the number 6174 so interesting? As defined by Wikipedia Take any four-digit number, using at least two different digits. (Leading zeros are allowed.) Arrange the digits in ascending ...
lunohodov's user avatar
  • 273
11 votes
6 answers

nth number with n distinct prime factors

A073329 is a sequence where the \$n\$th term is the \$n\$th number with exactly \$n\$ distinct prime factors. For example, \$a(3) = 60\$ as the first \$3\$ integers with \$3\$ distinct prime factors ...
Gregory Higley's user avatar
23 votes
25 answers

Look and say sequence [duplicate]

The look and say sequence is a basic form of run length encoding. The sequence starts with the number 1 and each additional number encodes the number of digits that are repeated before each digit ...
Thomas O's user avatar
  • 3,348
8 votes
4 answers

The fourth power (Juzuk) [closed]

In 1939 Juzuk described a way to generate the fourth powers of natural numbers. Group the natural numbers like this: ...
steenslag's user avatar
  • 2,150
7 votes
6 answers

Carmichael Numbers

Write a program to print Carmichael numbers. The challenge is to print the maximum number of them in less than 5 secs. The numbers should be in increasing order. Please do not use built in functions. ...
fR0DDY's user avatar
  • 4,577
150 votes
335 answers

Fibonacci function or sequence

The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first ...
C. K. Young's user avatar
  • 4,947
26 votes
14 answers

Hamming numbers

Hamming numbers are numbers which evenly divide a power of 60. Equivalently, their prime factors are all \$ \le 5 \$. Given a positive integer, print that many Hamming numbers, in order. Rules: Input ...
grokus's user avatar
  • 1,287

15 16 17 18