For challenges involving some sort of sequence.

learn more… | top users | synonyms

10
votes
6answers
390 views

Longest arithmetic subsequence

Given a non empty finite sequence of integers, return an arithmetic subsequence of maximal length. If there are multiple of the same maximal length, any of them can be returned. Definitions: An ...
10
votes
22answers
639 views

Alternating Sign Sequence

Introduction The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the ...
16
votes
20answers
3k views

Female and Male Sequences

This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison. Really looking forward to the answers! In his book ...
16
votes
19answers
940 views

Greatest Number in a Range When The Sum of Squares of its Prime Factors are Subtracted

The formula Take for instance the number 300 The prime factors of 300 are [2, 3, 5] (unique numbers that are factors of 300 and prime) Squaring each of those numbers will give you [4, 9, 25] ...
4
votes
14answers
669 views

Find the number I/O shortest algorithm

Find the shortest function/algorithm to translate these numbers to the ones after the dash: 0 - 0 1 - 10 2 - 20 3 - 30 4 - 40 5 - 50 6 - 60 7 - 70 8 - 80 9 - 90 10 - 100 11 - 115 12 - 130 13 - 150 14 ...
13
votes
13answers
2k views

Fibonacci products

You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.: 1 ...
3
votes
6answers
274 views

Convert header levels to numbers

Introduction Nodes in tree structures (e.g. headings in a long document, law paragraphs, etc.) are often created by assigning a specific header level (h1, h2, etc.) to each item, but outputted with ...
12
votes
7answers
549 views

Print the Nth non-palindromic number

Print the Nth non-palindromic number A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: 10, ...
18
votes
7answers
981 views

Generate n digits of Gijswijt's sequence

Introduction Gijswijt's sequence (A090822) is famously really, REALLY slow. To illustrate: The first 3 appears in the 9th term (alright). The first 4 appears in the 220th term (a long way away, but ...
18
votes
9answers
776 views

The Back-and-Forth Sequence

Imagine a path made up of < and > and ending in a @, e.g. ><>@ A walker starts on the left-most cell. He will traverse the path as follows: If the walker is on a @ cell, he's ...
8
votes
64answers
4k views

Count up folks!

Introduction It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive. This is not the same thing. That one is a (closed) not well-explained challenge. This is not ...
5
votes
3answers
135 views

Taylor Series of a Function with Periodic Derivatives

Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single ...
19
votes
11answers
1k views

Polynomialception

Given two polynomials f,g of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. f(g(x)) (a.k.a. the composition (fog)(x) of the ...
27
votes
18answers
959 views

Numbers with Rotational Symmetry

Given an integer, output a truthy value if it is the same upside-down (rotated 180°) or a falsy value otherwise. 0, 1, and 8 have rotational symmetry. 6 becomes 9 and vice versa. Sequence of numbers ...
13
votes
12answers
1k views

In-between fractions

In-between fractions The challenge: You will need to create code that takes atleast 3 inputs; 2 integers and "a fraction representation" - whichever type suits your language for representing the ...
20
votes
14answers
871 views

Generate the minimal remainder sequence

Every number can be represented using an infinitely long remainder sequence. For example, if we take the number 7, and perform 7mod2, then 7mod3, then 7mod4, and so on, we get ...
21
votes
27answers
3k views

All together now

Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a ...
19
votes
55answers
2k views

Find the program that prints this integer sequence (Robbers' thread)

This is the robbers' thread. The cops' thread goes here. In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another ...
35
votes
71answers
4k views

Find the program that prints this integer sequence (Cops' thread)

This is the cops' thread. The robbers' thread goes here. The last cops-and-robbers thread was already 4 months ago. The cop's task The cop's task is to write a program/function that takes a ...
21
votes
25answers
2k views

The plus-minus sequence

The plus-minus sequence The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the ...
27
votes
14answers
2k views

The Arithmetic Derivative

The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only ...
3
votes
4answers
124 views

Is this a Lucas number? [duplicate]

Write a program or function that takes an input greater than or equal to 2. It should output a truthy or falsy value corresponding to whether the input is a Lucas number or not. You may take input ...
10
votes
2answers
353 views

Tic-tac-toe with only crosses as quick as possible

As per Luke's request and Peter Taylor's addition to this challenge. Introduction Everyone knows the game tic-tac-toe, but in this challenge, we are going to introduce a little twist. We are only ...
16
votes
11answers
675 views

Create an ABACABA city

Here is the 3rd ABACABA city: _ A|_| B|__| A|_|_ C|___| A|_| B|__| A|_| It is made out of the ABACABA sequence, which is basically: A (1st iteration) place B - AB repeat A - ABA (2nd iteration) ...
4
votes
3answers
117 views

Golomb's sequence to 1000000 [duplicate]

This used to be an old Computer Olympiad Question, not sure what the actual source was. Assume function f: f(1) = 1 This f(1), f(2), f(3), f(4), ... sequence of numbers are in ascending order. ...
7
votes
6answers
364 views

Generate m-sequences

Introduction Maximum-length sequences, usually known as m-sequences, are binary sequences with some interesting properties (pseudo-noise appeareance, optimal periodic autocorrelation) which make them ...
10
votes
16answers
921 views

Print the difference in the Thue-Morse sequence

Note, when I say "negate", I mean replace all ones with zeroes (i.e. a bitwise negation) The Thue-Morse sequence goes like 01101001 The way you generate it is: Start by taking 0. Negate what is ...
17
votes
12answers
633 views

Equality in the sum of digits

Introduction Let's take the number 180. This is an interesting number because the sum of digits of this number is equal to: 1 + 8 + 0 = 9 And the squared version of this number, or: 180² = 32400 ...
27
votes
24answers
1k views

Decompose binary into alternating subsequences

This was inspired by Problem 13 - Non-Repeating Binary of HP CodeWars' recent competition. Let's take a random decimal number, say 727429805944311 and look at its binary representation: ...
8
votes
2answers
124 views

Generate E-series of preferred numbers

Resistors and other electronic components are typically manufactured with values that conform to one of the E-series of preferred numbers. IEC 60063 defines the following E-series: E6: 10 15 ...
36
votes
35answers
4k views

Making a coin fair

You have a coin that produces 0 or 1. But you suspect the coin may be biased, meaning that the probability of 0 (or 1) is not necessarily 1/2. A well known procedure to "transform" a biased coin into ...
20
votes
0answers
231 views

Cycles in run-length encoding

Consider some binary sequence, using 1 and 2, e.g.: 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ... Let's write down the run lengths of that: 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ... _ _ ____ ____ _ _ ...
10
votes
4answers
968 views

The Unholy numbers

This challenged is highly inspired by what @Mego created with his Holy and Holier numbers, lots of thanks to him and his puns. Holy numbers are numbers composed of only the digits with holes, which ...
20
votes
9answers
846 views

Highly composite numbers

A highly composite number is a positive integer that has more divisors than any smaller positive integer has. This is OEIS sequence A002182. Its first 20 terms are 1, 2, 4, 6, 12, 24, 36, 48, 60, ...
16
votes
21answers
631 views

Descending digit sequences

Introduction As an example, let's take the number 7. We then duplicate this and place 7 spaces in between. We get this: 7_______7 After that, we are going to decrease the number, until there are ...
21
votes
3answers
314 views

The Holier Numbers

As we learned from The Holy Numbers, there are 5 holy digits (0, 4, 6, 8, 9), and positive integers consisting solely of those digits are holy. Additionally, the holiness of a number is the sum of the ...
24
votes
32answers
1k views

Adding up the digits and the digits reversed

Given a number > 0, output the sum with all digits (1 .. n) concatenated and reversed and add them up. For example, with n = 6: The numbers 1 to 6 concatenated: 123456 Reversed: 654321 Adding ...
11
votes
9answers
234 views

Reading a timeline

Inspired by Draw a timeline. Given a timeline of events, output the date for each event. A timeline will be given in the form 2000 --AF-C-------E--D---B-- Where the first line shows a known ...
9
votes
1answer
150 views

Taxi me some numbers

Taxicab Numbers or OEIS A011541 are the least numbers that are able to be represented as n different sums of two positive cubed integers, for successive n. You'll need to print out the nth taxicab ...
19
votes
12answers
4k views

When will I have a binary car?

I noticed that my car's odometer was at 101101 when I got to work today. Which is a cool number because it's binary (and a palindrome, but that's not important). Now, I want to know when the next time ...
17
votes
13answers
1k views

The middle-square method

Introduction The middle-square method is used for the generation of pseudorandom numbers. However, this is not a good method in practice, since its period is usually very short and has some severe ...
18
votes
4answers
398 views

Singly lossy integers: Concatenated sequences missing a single element

I define the method of combining a sequence to mean that every number in the sequence is concatenated as a string, then that result is made an integer. [1, 2, 3] -> 123 For every finite sequence ...
45
votes
18answers
5k views

The Holy Numbers

In many fonts (specifically in the Consolas font), 5 out of the 10 decimal digits have "holes" in them. We will call these holy digits: 46890 The 5 unholy digits are thus: 12357 An integer may ...
15
votes
4answers
331 views

Find the missing number in an undelimited string

The challenge is to identify the missing number in a string of undelimited integers. You are given a string of digits (valid input will match the regular expression ^[1-9][0-9]+$). The string ...
16
votes
5answers
1k views

Chocolate numbers

Given an m by n chocolate bar, m,n positive, output the number of ways to break the bar into mn 1 by 1 pieces where each break occurs on a gridline. Order is important. Pieces are also ...
13
votes
20answers
1k views

Output the juggler sequence

The juggler sequence is described as follows. Beginning with an input a1, the next term is defined by the recurrence relation The sequence terminates when it reaches 1, as all subsequent terms ...
14
votes
9answers
315 views

Strict partitions of a positive integer

OEIS A000009 counts the number of strict partitions of the integers. A strict partition of a nonnegative integer n is a set of positive integers (so no repetition is allowed, and order does not ...
15
votes
1answer
359 views

Same-color arithmetic progressions

Van der Waerden's theorem says that For any given positive integers r and k, there is some number N such that if the integers {1, 2, ..., N} are colored, each with one of r different colors, ...
12
votes
6answers
817 views

Number of steps for a binary search

Given an input of a positive integer, output the number of steps it takes to find the input via a binary search starting at 1. We are simulating a binary search for the integer that was given as ...
27
votes
35answers
2k views

Output the van der Corput sequence

The van der Corput sequence is one of the simplest example of low-discrepancy sequence. Its n-th term is just 0.(n written in base 10 and mirrored), so its first terms are : 0.1, 0.2,0.3,0.4, ...