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β΅-)β©Β°β‘Β°β))