@chrispsn Did you see @coltim’s version of generating all subsequences on the Discord channel? Comparing to this shows you’re generating more sequences than you need but of course all’s fair in a golf. Mine generated more than I need too. I was just making an observation.
@doug I did see it - for this problem there might be a way of calculating the pair of numbers (length and offset) more directly, which would be more efficient (I doubt shorter but who knows) - will post if I come up with anything...
this should do it more efficiently but requires lots of work to golf down:
f:{b:1+!x / lengths
a:x{-1+(-y)!x-+/!y}'b / offsets
pairs:|a,'b / order in descending b
pairs:(0>*:')_pairs / filter out -ve offsets
i:({x=+/y+1+!z}[x].'pairs)?1 / index of first match
{x+1+!y}/pairs i} / generate sequence