Timeline for Split string on first occurrence of each character
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 29 at 19:51 | comment | added | Aaron | Thank you, that's starting to make a bit more sense for me. Impressive answer! | |
Feb 29 at 11:18 | comment | added | Zgarb |
@Aaron Then with Ġ I group the indices i of this list of strings: indices i and i+1 go in the same chunk if p[i] and p[i+1] have the same unique characters. Finally, with ị I index back to the original string s , essentially grouping it into chunks in the same way as the indices i .
|
|
Feb 29 at 11:17 | comment | added | Zgarb |
The list p of nonempty prefixes of s has the same length as s . For each index i , the string p[i] is the prefix of s up to and including s[i] . Two adjacent chars s[i] and s[i+1] should be in the same chunk in the output if s[i+1] already occurred before index i , or in other words, in the prefix p[i] . This is equivalent to p[i] and p[i+1] having the same set of unique characters. I compute with QƤ the unique characters of each prefix p[i] .
|
|
Feb 27 at 5:55 | comment | added | Aaron | Can someone explain the logic of this solution? I can see that it does work, but I can't get my head around why it works; like, I wouldn't have thought that indexing back into the original string where the deduped prefixes match would yield the answer. | |
Feb 19, 2018 at 20:06 | history | edited | Zgarb | CC BY-SA 3.0 |
added 371 characters in body
|
Feb 19, 2018 at 18:23 | history | answered | Zgarb | CC BY-SA 3.0 |