4 ms·
I do not understand why your solution skips to the next unique elements. Consider sequence [1,1,1,1,1,1]. We should count there 3 (three) (1,1) pairs. Karpathy
by thesz 3y ago
I do not understand why your solution skips to the next unique elements.
Consider sequence [1,1,1,1,1,1]. We should count there 3 (three) (1,1) pairs. Karpathy's (and mine's) algorithm would count 5 pairs, yours' will count 1.
One should just skip one or two elements counting pairs, one element when pair's elements are different, two when they are same. This may break vectorization, though.
I also should note that error is here, but no-one hits it. My experiments show that (A,A) pairs gets counted as most frequent ahead of their natural turn about half a dozen symbols earlier. I also never saw that symbol B, assigned for pair (A,A), is used in any most frequent pair before an actual turn for (A,A). One need to construct special string for that to happen.
- theGnuMe 3y agoIt sounds like that sequence is being k-merized. In the case of byte-pair that should be a look-ahead of 1 and then a shift up of 1. Maybe I am missing something.