Uiua
Straightforward until part3. I left the naive approach running while I put together the version below, but of course the better algorithm got there first.
Prep ← (
⍉˜⊟°⊏≡□ # store char with index
⊕(⊟⊃(⊢⊢|□≡(°□⊣)))⊛⊸≡◇⊢ # group them
⍉↯∞_6⊏⍏⊸≡(°□⊢⊢) # re-arrange
▽=1◿2°⊏ # drop labels, as we never used them...
)
/+/+⊞>∩°□°⊟⊢Prep "ABabACacBCbca" # Part1
/+≡(/+/+⊞>∩°□°⊟)Prep "ABabACacBCbca" # Part2
# Note that the pattern repeats, so the only distinct values
# are in the first run and last run. Everything in between
# will be identical. Only works when distance < string length...
⟜Prep "AABCBABCABCabcabcABCCBAACBCa"
Rep ← 2
Split ← [1 -2Rep 1] # multipliers for the three results for each profession.
Dist ← 10
≡(≡(⊟∩□)⊃(≡+⊙(¤°□⊢)|¤♭≡+⊙(¤°□⊣)))¤×⇡3⧻ # Create the start, middle, end set for each.
/+≡(/+×Split≡(/+/+⊞(≤Dist⌵-)∩°□°⊟))