Kolakoski sequence: Difference between revisions
Content added Content deleted
m (fmt.) |
m (fmt, series-> sequence) |
||
Line 1: | Line 1: | ||
{{draft task}} |
{{draft task}} |
||
The [[wp:Kolakoski sequence|Kolakoski sequence]] is an infinite sequence of [[wp:Natural number|natural numbers]], (excluding zero); with the property that: |
The [[wp:Kolakoski sequence|Kolakoski sequence]] is an infinite sequence of [[wp:Natural number|natural numbers]], (excluding zero); with the property that: |
||
: ''if you form a new sequence from the counts of runs of the same number in the first |
: ''if you form a new sequence from the counts of runs of the same number in the first sequence, this new sequence is the same as the first sequence''. |
||
;Example: |
;Example: |
||
Line 17: | Line 17: | ||
;Creating a Kolakoski sequence: |
;Creating a Kolakoski sequence: |
||
Lets start with the two numbers <code>(1, 2)</code> that we will cycle through; i.e. they will be used in this order:<br> <code>1,2,1,2,1,2,....</code> |
|||
# We start the sequence <code>s</code> with the first item from the cycle <code>c</code>:<br> <code>1</code> |
# We start the sequence <code>s</code> with the first item from the cycle <code>c</code>:<br> <code>1</code> |
||
Line 27: | Line 27: | ||
<ol start="3"> |
<ol start="3"> |
||
<li><p>Increment <code>k</code></p></li> |
<li><p>Increment <code>k</code></p></li> |
||
<li><p>Get the next item from <code>c</code> and append it to the end of |
<li><p>Get the next item from <code>c</code> and append it to the end of sequence <code>s</code>. <code>s</code> will then become:<br> <code>1, 2</code></p></li> |
||
<li><p><code>k</code> was moved to the second item in the list and <code>s[k]</code> states that it should appear two times, so append another of the last item to the |
<li><p><code>k</code> was moved to the second item in the list and <code>s[k]</code> states that it should appear two times, so append another of the last item to the sequence <code>s</code>:<br> <code>1, 2,2</code></p></li> |
||
<li><p>Increment <code>k</code></p></li> |
<li><p>Increment <code>k</code></p></li> |
||
<li><p>Append the next item from the cycle to the list:<br> <code>1, 2,2, 1</code></p></li> |
<li><p>Append the next item from the cycle to the list:<br> <code>1, 2,2, 1</code></p></li> |
||
<li><p><code>k</code> is now at the third item in the list that states that the last item should appear twice so add another copy of the last item to the |
<li><p><code>k</code> is now at the third item in the list that states that the last item should appear twice so add another copy of the last item to the sequence <code>s</code>:<br> <code>1, 2,2, 1,1</code></p></li> |
||
<li><p>increment k</p></li></ol> |
<li><p>increment k</p></li></ol> |
||