Together, that's full code for industrial-strength forward and inverse BWT. All that's missing is some method of avoiding degeneracy in the forward transform string sort (e.g., noising long runs in the input or a suffix array).
and you're done. Once you understand the forward transform, you understand that root is the LAST byte and next[root] is the FIRST byte.
All the fixes in BUGFIX-66 are trivial if you understand what the code is doing, that's part of the game concept. Also, if you submit broken code, it gives you a useful hint to direct your attention to the bug.
Similarly, the fix for the forward transform is to add
https://bugfix-66.com/7f0f425d3eee8def16e1102d054fd45394d027...
Wikipedia gives an impractical, inefficient account of the algorithm. It's almost comically bad.
But the BWT has an efficient inverse transform with very short, simple code, as seen above. This is the classic linked list algorithm.
The forward transform is also simple if done right. See the Go code here:
https://bugfix-66.com/72949624ebbb28b3d0ce5d700970a8857d354b...
Together, that's full code for industrial-strength forward and inverse BWT. All that's missing is some method of avoiding degeneracy in the forward transform string sort (e.g., noising long runs in the input or a suffix array).