My solution, based on coroutines and Flow:
https://github.com/jakubgwozdz/AdventOfCode/blob/master/src/advent2019/day17/Route.kt
most difficult part was algorithmically finding the routine and functions A, B, C.
I did it by testing all possible subpaths and adding some optimizations:
• function A is 1 up to 5 first elements of path
• function C is 1 up to 5 last elements of path
• function B is any 0 up to 5 elements of path
• main routine is 10 calls long, starts with A, ends with C, and has 0 to 8 calls of A,B,C inside
And then I perform a loop that takes every combination of A,B,C and main and tests if it results in previously found scaffolding route
I wonder if I could do it less brutey forcey