ITT we prove that the Kolakoski sequence has the same density of 1s and 2s.
It's defined as the unique sequence of only 1s and 2s starting with 12 such that the [math]n^{th}[/math] element defines the run length of the [math]n^{th}[/math] run of elements.
The sequence starts as follows: 12211212212211211221211. It's also not hard to calculate either once you're used to it, so don't get put off too fast.
Notice that when we group the runs of elements and create the sequence of their lengths, we recover the original sequence.
[1][22][11][2][1][22][1][22][11][2][11][22][1][2][11]
Taking the size of each bracketed group we get 122112122122112, which matches the original sequence.
Conversely, by grouping every pair of elements, and then expanding them with the following rules, we also recover the original sequence.
Here are the rules.
[math]11 \rightarrow 12[/math]
[math]12 \rightarrow 122[/math]
[math]21 \rightarrow 112[/math]
[math]22 \rightarrow 1122[/math]
Group every other pair of consecutive elements in the sequence, and then expand using the rules.
[12][21][12][12][21][22][11][21][12][21][21]
122112122122112112212112122112112
Again, we recover the original sequence.
Note that this last mentioned property can used to generate the sequence.
Also, better methods exist, with the best I've seen allowing you to calculate that [math]n^{th}[/math] element of this sequence using O(log(n)) memory rather than O(n) memory as the naive method hinted at above would use.
Let's do this shit senpaitachi.