--
You received this message because you are subscribed to the Google Groups "SeqFan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seqfan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CAL0FETm%2Bmre6Uo7c9MBWihQVSMOvJUysLD4qfmoK3QOtxYv6UA%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CA%2BZ5DMX3usLKsJAnOyw-B%2B0ToL1w8R94C4JNru-mNxCbvm_M7Q%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CAL0FETnmi1iksoXUSnYgzt88hzTgr1N_Z8EMJ0y1yo5vvnqMRg%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CAE7BzufSfKOZXkC0u7JHpgaw_MJF2n9UgGpBvTq1oa_reJRyYg%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CALSFKfgowu0W8RC1VMCwm36VG5tbi2LX2mUQQZDqZ5pqp6UNRQ%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/27a7af2a-f889-4313-a902-5e27a9aa76d5n%40googlegroups.com.
Hi Sean and all,
I took a closer look at A086183 and ended up writing a considerably faster exact implementation.
For a fixed (n), the program builds a suffix automaton for the first block (X_n) and scans the overlapping block (Y_n). At each ending position in (Y_n), it is enough to consider the longest suffix that also occurs in (X_n); after removing any leading zeros, this gives the largest candidate ending at that position. A precomputed next-nonzero table handles the zeros, and suffix ranks from an SA-IS suffix array are used to compare equal-length candidates exactly.
For computing all terms (a(1),\ldots,a(N)), the suffix automaton is extended incrementally as (n) increases, while the suffix ranks are built only once. The resulting complexity is
[
O(N^2)
]
time and (O(N)) working memory. A single specified term can be computed in (O(n)) time. The implementation does not use rolling hashes or probabilistic comparisons.
I also compared it with a faithful runnable transcription of Darío’s Python approach from this thread. Using the same exact digit file, suppressing sequence output, and timing only the core computation, I obtained approximately:
These figures are naturally machine-dependent, but the gap increases with (N). Compared with the earlier direct-enumeration program, the difference is much larger, although Darío’s version seems the fairer baseline.
For verification, the package includes an independent brute-force oracle, exhaustive tests on small binary strings, randomized decimal tests, and an independent check of the SA-IS suffix ranks. The first 1000 terms agree term-by-term with the posted Python approach, and the known initial terms through (n=61) are also reproduced.
I have attached both the standalone C++20 source and a small package containing an English README, the correctness argument, CMake support, benchmark scripts, reference timings, and checksums.
This may be useful for adding a more efficient program and explanation to A086183.
Best,
Jason Dong
To view this discussion visit https://groups.google.com/d/msgid/seqfan/CABjGZ_D86N_rkQ2kM9OXgXKOtJcpZTc2FEb0qF0uJ1AXcFAczQ%40mail.gmail.com.