For challenges involving some sort of sequence.
20
votes
22answers
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 ...
26
votes
13answers
1k 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
97 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 ...
8
votes
2answers
315 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 ...
15
votes
11answers
604 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
112 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
349 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
906 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
616 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:
...
-13
votes
8answers
206 views
ABACABADABACABA generator [closed]
There is sequence that goes like :
abacabadabacaba
etc.
The simplest way to explain how the sequence works is this:
Start with a.
Place the next letter in the alphabet in front of the current ...
8
votes
2answers
121 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 ...
19
votes
0answers
197 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
952 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
820 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
20answers
600 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
310 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 ...
23
votes
31answers
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
232 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
135 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 ...
18
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
392 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
19answers
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
329 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
302 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
354 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
813 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, ...
18
votes
18answers
3k views
The Lucas-nacci Numbers
Background
Most everyone is familiar with the Fibonacci numbers F(n):
0, 1, 1, 2, 3, 5, 8, 13, 21 ...
These are formed by the recursion function F(n) = F(n-1) + F(n-2) with F(0)=0 and F(1)=1. ...
1
vote
1answer
69 views
“Fouriest” Transform of An Integer [duplicate]
Challenge
Inspired by this SMBC comic, discussed on reddit, math.stackexchange, and calculus7, the challenge is to return the lowest base such that a number is "fouriest."
Description
[From the ...
17
votes
18answers
534 views
Find the nth cross-alternate sum
Given an input of a single positive integer, output the "cross-alternate sum"
that corresponds to that integer.
Take the example of the input n=5. To find the cross-alternate sum, first
create a ...
17
votes
8answers
342 views
Print the Super Collatz numbers
The Collatz Sequence (also called the 3x + 1 problem) is where you start with any positive integer, for this example we will use 10, and apply this set of steps to it:
if n is even:
Divide it by ...
20
votes
17answers
996 views
Rearranging the sequence
Introduction
Let's observe the following sequence (non-negative integers):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ...
For example, let's take the first three numbers. These are 0, 1, 2. ...
16
votes
13answers
463 views
Say What You See
The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last.
1
11 (one one)
21 (two ones)
1211 (one two one one)
111221 (one one one two two ones)
312211 ...
16
votes
8answers
601 views
Spiral Permutation Sequence
We can roll up the natural numbers in a rectangular spiral:
17--16--15--14--13
| |
18 5---4---3 12
| | | |
19 6 1---2 11
| | |
20 7---8---9--10
...
10
votes
6answers
281 views
Squares in the Squares
Given input of a positive integer n, write a program that completes the following process.
Find the smallest positive integer greater than n that is a perfect square and is the concatenation of n ...
13
votes
3answers
279 views
Reverse-Engineer the N-Bonacci sequence[s]
EDIT: I will be accepting an answer Monday, 2/15/2016. May the bytes be ever in your favor!
In his "Print the N-Bonacci Sequence" challenge, @DJMcGoathem describes the N-bonacci sequences, wherein ...
25
votes
18answers
2k views
The RATS sequence
Your task is to generate the nth term of the RATS sequence, where n is the input. The RATS sequence is also known as the Reverse Add Then Sort sequence. This sequence can also be found here: ...
19
votes
15answers
2k views
Hypercube elements
Write a function or program that outputs the number of each type of element (vertex, edge, face, etc.) of an N-dimensional hypercube.
As an example, the 3 dimensional cube has 1 cell (i.e. 1 ...
21
votes
12answers
781 views
Matching Adjacent Words
In this challenge, you are passed two words: Your job is to determine if they are adjacent.
Two letters are adjacent if:
They are the same letter, or
They are lexicographically adjacent.
For ...
20
votes
26answers
7k views
List Prime Numbers [duplicate]
Introduction
Prime numbers are simple, right? Well, now you get your chance to find out!
Challenge
You must write a program or function that takes an input n and outputs the first n prime numbers.
...
19
votes
20answers
2k views
The Möbius Function
The Möbius Function
The Möbius function is an important number theoretic function.
Your submission should accept a positive integer n and return the value of the Möbius function evaluated at n.
...
5
votes
0answers
155 views
Look and Say sequence in any base
We all already crossed the look and say sequence, and where asked to guess the next element. As its name tells it very well, you just have to say what you see :
1
1 1
2 1
1 2 1 1
1 1 1 2 2 1
3 1 2 2 ...
18
votes
7answers
730 views
Generate Programs in Increasing size
In this challenge, you will write a program which outputs a program which is the double the length of the original program. The outputted program should output a new program a program double its ...
6
votes
0answers
159 views
Help me fill my wallet!
A while ago I purchased a new wallet which is able to hold 8 cards (4 on both side). However, I seem to have way more cards than that and I need to make choices on which ones I want to carry with me. ...
18
votes
7answers
880 views
Find the capacity of 2D printed objects
In a fictional 2D world, a set of 2D printing instructions for an object can be represented by a list of integers as follows:
1 4 2 1 1 2 5 3 4
Each number represents the height of the object at ...