How to resolve the algorithm Kolakoski sequence step by step in the Phix programming language
How to resolve the algorithm Kolakoski sequence step by step in the Phix programming language
Table of Contents
Problem Statement
The Kolakoski sequence is an infinite sequence of natural numbers, (excluding zero); with the property that: This is not a Kolakoski sequence: Its sequence of run counts, (sometimes called a run length encoding, (RLE); but a true RLE also gives the character that each run encodes), is calculated like this: The above gives the RLE of: The original sequence is different from its RLE in this case. It would be the same for a true Kolakoski sequence. Lets start with the two numbers (1, 2) that we will cycle through; i.e. they will be used in this order: 1,2,1,2,1,2,.... We will arrange that the k'th item of s states how many times the last item of sshould appear at the end of s. We started s with 1 and therefore s[k] states that it should appear only the 1 time. ... Note that the RLE of 1, 2, 2, 1, 1, ... begins 1, 2, 2 which is the beginning of the original sequence. The generation algorithm ensures that this will always be the case. (There are rules on generating Kolakoski sequences from this method that are broken by the last example)
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Kolakoski sequence step by step in the Phix programming language
Source code in the phix programming language
You may also check:How to resolve the algorithm Filter step by step in the Brat programming language
You may also check:How to resolve the algorithm Smith numbers step by step in the Perl programming language
You may also check:How to resolve the algorithm 24 game/Solve step by step in the Racket programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Beef programming language
You may also check:How to resolve the algorithm Brace expansion step by step in the Sidef programming language